
Loading ...
180 views
10.28.2008 by HappyFace in
Java

An example to show "stars" in the command line interface. (Replace the "x" into "*" ) This is a common homework question but frequently asked for in the Java forums that i go to so here it is.
JAVA:
-
public class CLIStars {
-
public static void main
(String[] args
){
-
int row = 9;
-
-
-
-
for (int i=0; i <row; i++){
-
-
text = text + "x";
-
}
-
-
for (int y=1; y<=row; y++){
-
for(int j=1; j<=row-y; j++)
-
System.
out.
print(textReverse
);
-
-
-
}
-
}
-
}
Output
x
xx
xxx
xxxx
xxxxx
xxxxxx
xxxxxxx
xxxxxxxx
xxxxxxxxx
xxxxxxxx
xxxxxxx
xxxxxx
xxxxx
xxxx
xxx
xx
x
Bookmark this page:
These icons link to social bookmarking sites where readers can share and discover new web pages.
Related posts
- April 6, 2008 -- Java Employee.class, Employee, Manager, Executive and HourlyWorker (0)
- December 29, 2008 -- New java challenges! (0)
- December 27, 2008 -- Java games at java4k, maximum fun, minimum size (0)
- December 24, 2008 -- Left 4 Dead Java version (0)
- December 22, 2008 -- Send and recieve images through network using java #2 (0)
- November 24, 2008 -- Eating monsters problem (0)
- November 17, 2008 -- [Java] Call a method from another class (0)
- November 17, 2008 -- [Java] parse a String to an int (0)
- October 28, 2008 -- Get the rgb value of an image in java (0)
- September 17, 2008 -- Online Java compiler W.I.P. (1)