18 Answers
New AnswerI just want the results to have space in between them .the results are stacked together public class Program { public static void main(String[] args) { String[][] grids = { {"shoe","clothes","cap"}, {"watch","cream","tshirt"}, {"brace","socks","boxers"}, }; for(int i=0;i<grids.length;i++){ for(int j=0;j<grids[i].length;j++){ System.out.print(grids[i][j]); } System.out.println(); } } }
1/15/2022 11:19:48 PM
Tony Jadesola18 Answers
New AnswerTony Jadesola, it could have been done as you tried, but not println, but print: System.out.print(' '); I advise you to carefully reread the lesson on the topic "Data Output".
Tony Jadesola, this course is a negligible part of JAVA. Who knows, it may take you a lifetime to learn JAVA, because while you just started learning, and at this very moment, programmers continue to expand the capabilities of Java. Good luck in your studies! ☺️
Add two tabs, ("\t"), to the output and not only will you have spaces, but everything will align with columns.
Tony Jadesola, you do not know where you have the data output???😶 System.out.print(grids[i][j]+"\t\t"); Agree, it is much easier to use someone else's code than to think a little and try to write it yourself. ☺️
Tony Jadesola, 🤣🤣🤣 now it is clear why you have not learned to make even spaces between variables. Ask yourself the question: “What is more important for me to complete the course as quickly as possible, or to assimilate the material of this course as best as possible in order to learn how to program?".
Solo true am still practicing what ave learned cause it looks like I didn't know it well
Tony Jadesola in your case it is probably better to use neither println nor print. I suggest printf. You can call System.out.printf("%s ", grids[i][j]) If you want each output on a new line you need to append a linebreak (\n) to each Output.
@solo I don't understand where you said I should add two tabs What I did was I added another System.out.println(); Results was like this: Shoeclothescap Watchcreamtshirt Bracesocksboxers As you can see it only gives space to the row(or column anyhow it's called)
Solo lol 😆 even if I use his code I still want to know how it works that's why I used your own
@solo I started java yesterday and I finished arrays today .how long do u think will take me to finish java
Clay lay learn python well and practice it's as simple as that And don't rush like me
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message