Dilip Nedungadi

Greenhorn
+ Follow
since Jun 23, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dilip Nedungadi

Parag and Rob are right. Run this prog and see for yourself
//TestStringprint.java
public class TestStringprint
{
public static void main(String[] args)
{
System.out.println(""+2 + 3);
System.out.println(2 + 3);
System.out.println(2 + 3 +"");
System.out.println(2 + "" +3);
}
}
Jeban is right. Note that r is an automatic variable. It is not necessary to initialize an automatic variable at the time of declaration, but it should be initialized before usage, else a compiler error occurs. In contrast member variables can be used without initialization, in this case the default value of the member variable is used.
Regarding your second question, observe that | | is a shortcircuit Conditional OR operator. The second operand will not be evaluated if the first operand of this operator returns true. So the second expression j+=2 is not evaluated since the first operand t is true. Change t to false and notice the difference.
On the other hand | is a Boolean Logical Operator and both the operands are always evaluated.
Hope this helps
Thanks,
Dilip
[This message has been edited by Dilip Nedungadi (edited October 18, 2000).]
[This message has been edited by Dilip Nedungadi (edited October 18, 2000).]
Please see the code below. The code runs and displays 0 as output, even though the Print command is called after the line x = x++; have executed completely. I was expecting 1 as output. Please help...
//LangSpecs.java
public class LangSpecs
{
public static void main(String[] args)
{
int x = 0;
x = x++;
System.out.println("Value of x is : " +x);
}
}