Advertisements

Learn Java using simple tutorial

Postby tutorialspoint » Thu Dec 17, 2009 7:34 pm

Offline
tutorialspoint
Site Admin
Posts: 139
Joined: Fri Apr 27, 2007 6:52 pm
Dear visitors,

If you are new to Java or finding difficulty in learning Java technology then tutorialspoint is here to help you with their simple and practical tutorial:

http://www.tutorialspoint.com/java/index.htm


Leave you feedback for improvement.
Moderator, TP
Keep visiting and share this site with your friends.

HELP

Postby mmiteshh » Tue Sep 04, 2012 5:18 pm

Offline
mmiteshh
Posts: 1
Joined: Tue Sep 04, 2012 5:08 pm
Location: India
Class Foozit {
public static void main(String args[]) {
Integer x=0;
Integer y=0;
for(short z=0;z<5;z++)
if((++x>2)||(++y>2))
x++;
System.out.println(x+ "" +y);
}
}


Its output is 8 2
Please anybody help me with the detailed step-wise information how the for and if loop is working here?
Thanks.
MIt

Learn Java using simple tutorial

Postby hasibmujtaba » Sat Sep 08, 2012 2:16 am

Offline
hasibmujtaba
Posts: 1
Joined: Sat Sep 08, 2012 2:05 am
Location: India
Class Foozit {
public static void main(String args[]) {
Integer x=0;
Integer y=0;
for(short z=0;z<5;z++)
if((++x>2)||(++y>2))
// it is the speciality of short circuit OR operator '||' i.e. it checks the the left condition first ,if it is
// true then it does not check the right one .i.e. y is not incremented after 2 since the left one
// condition is true
x++;
System.out.println(x+ "" +y);
}
}


Its output is 8 2

»JAVA Tutorials

Postby morph34a » Wed Dec 19, 2012 12:49 pm

Offline
morph34a
Posts: 1
Joined: Wed Dec 19, 2012 12:37 pm
Location: Chandigarh
Thanks for the useful java tutorials.