-4

I have to create a reference like example 1 x 5 (one row and 5 columns) having the symbol *. so my output should look like *****. Im new to java and also would like to know a good book to practice the language.Can someone tell me how to obtain the output?

Arun Mathew
  • 1
  • 1
  • 2

3 Answers3

0

Read some java basics, here are some personal recommendations,

  1. Thinking in Java, by Bruce Eckel
  2. Head First with Java
  3. Java for Dummies
  4. Effective Java by Joshua Bloch

and ofcourse,

you can always refer to Java documentations, https://docs.oracle.com/javase/8/docs/

If someone have some more options, please feel free to edit the post.

drink-a-Beer
  • 389
  • 1
  • 5
  • 14
0
   public class PrintSymbol
    {
        public static void main(String[] args)
        {
            //++row or prefix increment because of better loop performance
            //print * while row <=5
            for(int row=1;row<=5;++row)
            {
                System.out.print("*");
            }
        }

}

about the book that you are saying please buy a book entitled "Java Programming" by Joyce Farrell, she is a great university teacher and her book is on point for the beginner

0xDEADBEEF
  • 590
  • 1
  • 5
  • 16
-3

you can use very code

for example

for(byte row = 1 ; row <= 5 ; row++)
   System.out.println("*");

or

for(byte row = 1 ; row <= 5 ; row++)
    System.out.print("*\n");
  • 2
    And yet you managed to provide a wrong answer, which doesn't respect Java naming conventions, and is not idiomatic at all. – JB Nizet Mar 19 '17 at 10:57
  • The edit is still wrong. And if you feel the need to add *"your Questions is so easy!!!"* then you probably shouldn't be writing an answer at all. Basic questions like these should be closed and OP redirected to proper tutorials – UnholySheep Mar 19 '17 at 11:01
  • @UnholySheep Thanks for your help – MohammadReza Ghafarpour Mar 19 '17 at 11:03
  • Execute it, and you'll see that it doesn't generate one row and 5 columns, but 1 column and 5 rows. – JB Nizet Mar 19 '17 at 11:18