File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static char doesnt display in System.out.println() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static char doesnt display in System.out.println()" Watch "static char doesnt display in System.out.println()" New topic
Author

static char doesnt display in System.out.println()

Praveen Babu
Ranch Hand

Joined: Jul 30, 2006
Posts: 138
Hi All,



doesnt give any thing and blocks all next statements from displaying

while,



returns 0 // this is ok
Why is this so ?

Bye & Regards,
Praveen

[ August 02, 2006: Message edited by: praveen babu ]
[ August 02, 2006: Message edited by: praveen babu ]
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
you did not init. c variable and the default value is '\u0000' (invisible).
Praveen Babu
Ranch Hand

Joined: Jul 30, 2006
Posts: 138
Hi,

If default value is invisible then how come it took part in the arithmetic
calculation in the next code and why is it blocking code below it to display. Please can you clarify ?

Regards,
Praveen
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
15.18.2 Additive Operators (+ and -) for Numeric Types

Binary numeric promotion is performed on the operands (�5.6.2). The type of an additive expression on numeric operands is the promoted type of its operands. If this promoted type is int or long, then integer arithmetic is performed; if this promoted type is float or double, then floating-point arithmetic is performed.


"a + c" will be an int '0'.
[ August 02, 2006: Message edited by: wise owen ]
Praveen Babu
Ranch Hand

Joined: Jul 30, 2006
Posts: 138
Hi,

Thanks Wise for your reply,

-Now i know why the final output is 0.
-Is the compiler unable to display the '\u0000' (invisible) char ? Is this the reason why it doesnt print lines after it
for example,



In the above code hello is not printed.

Please clarify,

Regards,
Praveen
[ August 02, 2006: Message edited by: praveen babu ]
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
I use Window XP and Java 5.0. Your code printed out a rectang graphics and Hello string.
Praveen Babu
Ranch Hand

Joined: Jul 30, 2006
Posts: 138
Hi wise,

Thanks you. Actually i am compiling it from an editor(Edit plus) which is not displaying it.From command line iam able to see hello.

Thank You & Regards,

Praveen
 
 
subject: static char doesnt display in System.out.println()