p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Java 2 (http://p2p.wrox.com/forumdisplay.php?f=30)
-   -   Chapter 4 Errors? (http://p2p.wrox.com/showthread.php?t=13206)

DRAYKKO May 20th, 2004 07:48 AM

Chapter 4 Errors?
 
I noticed a couple of errors while working through some of the samples in Chapter 4 of this book:

1. On page 123 the Unicode character \U03C0 doesn't generate Pi as the book says, but rather the character "?".

2. On page 125 the following code generates an error when I use the NetBeans editor:

   if(anyString == null)
     System.out.println(...)


The error is: non-static variable anyString cannot be referenced from a static context
        if(anyString == null)


Is there a site that lists Unicode characters and is there a correction for that "non-static..." error?

Dre---
---------------------------------

That which does not kill me makes me stronger

freezotic May 27th, 2004 03:03 AM

Quote:

quote:Originally posted by DRAYKKO



1. On page 123 the Unicode character \U03C0 doesn't generate Pi as the book says, but rather the character "?".

1. The ? means your system does not recognize the unicode character.
The display of unicode depends on the local machine implementation.
You can make a test loop to see what can be displayed and what characters are out of reach for your system. E.g.

for(int i = 0; i < 256; i++)
    System.out.println(i + " " + (char)i);

Quote:

quote:
2. On page 125 the following code generates an error when I use the NetBeans editor:

if(anyString == null)
     System.out.println(...)


The error is: non-static variable anyString cannot be referenced from a static context
        if(anyString == null)

2. This happens quite often, and is not hard to fix. The problem is that you are calling an instance variable from a static context, e.g. the static method main().
Here you can either take care that:
- anyString is static
- the method that calls anyString is an instance method

This will improve your programming structure.

Frans






freezotic May 29th, 2004 02:47 PM

Quote:

quote:Originally posted by DRAYKKO


1. On page 123 the Unicode character \U03C0 doesn't generate Pi as the book says, but rather the character "?".

Is there a site that lists Unicode characters and is there a correction for that "non-static..." error?
http://www.unicode.org
but as I said before: its the local system's implementation of the unicode that is decisive here


DRAYKKO June 1st, 2004 07:47 AM

Thanks for the help! I'll try the code to define the Unicode characters.

Dre---
---------------------


That which does not kill me makes me stronger


All times are GMT -4. The time now is 04:17 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.