7stud
02-03-2005, 10:59 PM
I have a function that returns zero converted to a char. It seems to me the return value should be the character '0', but when I try to display it using System.out.println(), the zero character doesn't display and a subsequent System.out.println("finish") doesn't display anything either. How come I can't get zero to display?
cross posted here:http://www.sitepoint.com/forums/showthread.php?t=230885
class SomeClass
{
char func()
{
return (char) 0;
}
};
class TestReturn
{
public static void main(String[] args)
{
SomeClass c = new SomeClass();
System.out.println('0'); //output the character zero
System.out.println("start");
for(int i = 0; i < 3; i++)
{
System.out.println(c.func());
}
System.out.println("finish");
}
}
Instead, I get this for output:
---------- java ----------
0
start
Output completed (2 sec consumed)
cross posted here:http://www.sitepoint.com/forums/showthread.php?t=230885
class SomeClass
{
char func()
{
return (char) 0;
}
};
class TestReturn
{
public static void main(String[] args)
{
SomeClass c = new SomeClass();
System.out.println('0'); //output the character zero
System.out.println("start");
for(int i = 0; i < 3; i++)
{
System.out.println(c.func());
}
System.out.println("finish");
}
}
Instead, I get this for output:
---------- java ----------
0
start
Output completed (2 sec consumed)