Tell me the programme for this


@
1 2
@ @ @
1 2 3 4

Answer Posted / sachin

package abc;

public class Sachin {

int n=4;
public static void main(String... args){
Sachin s=new Sachin();
for (int i=0;i<s.n;i++){
if(i%2==0){
for(int a=0; a<i+1;a++){
System.out.print("@");
}
}else{
for(int a=0; a<i+1;a++){
System.out.print(a+1);
}
}
System.out.println();
}
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages of java over C++?

708


What is JDBC Driver interface?How can you retrieve data from the ResultSet

1501


explain copyonwritearraylist and when do we use copyonwritearraylist?

530


What is java console application?

552


What is a finally block? Is there a case when finally will not execute?

540






What is the exception hierarchy in java?

477


What is the difference between access specifiers and access modifiers in java? 16

532


What is the difference between the font and fontmetrics classes in java programming?

490


How do you add an element to a set in java?

491


Can you run java program without main method?

538


What is a priority queue java?

511


Can we sort array in java?

519


What is initial size of arraylist in java?

531


What restrictions are placed on method overriding?

633


How do you find the independent variable?

502