how to print the below in java?
* *
* *
*
* *
* *

Answers were Sorted based on User's Feedback



how to print the below in java? * * * * ..

Answer / ganesh slv

/**
* Printing Stars - 24.03.10
* @author Ganesh
*/

public class Star {

/**
* Please Send me Your Comment - slvganesh.java@gmail.com
*/

public static void main (String arg[]) {

int n = 6;
for (int i=0, j=n; i<=n; i++,j--) {
for (int k=0; k<=n; k++) {

if (i==k || j==k)
System.out.print ("*");
else
System.out.print (" ");
}
System.out.println ();
}
} // Main
} // Class

Is This Answer Correct ?    17 Yes 1 No

how to print the below in java? * * * * ..

Answer / kickme

public static void main (String arg[]) {
System.out.println(" * * ");
System.out.println(" * * ");
System.out.println(" * ");
System.out.println(" * * ");
System.out.println(" * * ");
}

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More Core Java Interview Questions

How to write custom exception in java?

0 Answers   Cyient,


How can u increase the heap size in the memory?

0 Answers   Infosys,


Is it possible to declare abstract class as final?What happens if we do so?

1 Answers  


Is it possible to use string in the switch case?

0 Answers  


What is nested loop? What is dangling else condition in it?

0 Answers   Ericsson,






What is busy spin, and why should you use it?

0 Answers  


Write a method to check if input string is palindrome?

0 Answers  


What is the main purpose of serialization in java?

0 Answers  


what are literals in java?

2 Answers  


whats the difference between == and .equal ?

10 Answers   Cisco,


What is a vararg?

0 Answers  


Is map ordered in java?

0 Answers  


Categories