Think Output:
Program #1:
- package com.instanceofjavaforus;
- public class Loops {
- public static void main(String args[]){
- int i=0;
- for( i=0;i<5;i++){
- System.out.println(i);
- }
- System.out.println("value of i after completion of loop: "+i);
- }
- }
Program #2:
- package com.instanceofjavaforus;
- public class LoopsDemo2 {
- public static void main(String args[]){
- int a=0,b=0;
- for(int i=0;i<5;i++){
- if(++a>2||++b>2){
- a++;
- }
- }
- System.out.println("a= "+a+" b="+b);
- }
- }
Program #3:
- package com.instanceofjavaforus;
- public class LoopsDemo3 {
- public static void main(String args[]){
- int i=5;
- System.out.println(i++);
- System.out.println(i--);
- }
- }
the ans and qns are very good for experienced people.
ReplyDeleteGood example
ReplyDeleteKindly post explanation
ReplyDeletewhich one sir?
Deletesir kindly post the explanation for 2nd program
Deleteplease give me explanation
ReplyDeletekindly post the explanation of Programs# 2 ?? Not getting.
Deletekindly give the explanation of programs# 2 not getting the output
Deleteclass J
Delete{
public static void main(String args[])
{
int a=0,b=0;
for(int i=0;i<5;i++)
{
if(++a>2||++b>2)
{
a++;
System.out.println("i:"+i);
System.out.println("a:"+a);
System.out.println("b:"+b);
}
}
System.out.println("a= "+a+" b="+b);
}
}
try this ..
you will get it .
Nice post to understand pre-implementation and post-implementation
ReplyDeleteKindly explain program 2
ReplyDelete