It's possible to display directly an array? For example : System.out.print({{3,2} , {5,5} }; | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 5

It's possible to display directly an array? For example : System.out.print({{3,2} , {5,5} };

java

10th Nov 2017, 4:53 PM
$_Raf_Orlando
$_Raf_Orlando - avatar
8 Antworten
+ 5
int[] intArr = {1,2,3,4,5,6,7,8,9,10}; System.out.println(intArr[0]); System.out.println(intArr[1]); System.out.println(intArr[2]); System.out.println(intArr[3]); System.out.println(intArr[4]); System.out.println(intArr[5]); System.out.println(intArr[6]); System.out.println(intArr[7]); System.out.println(intArr[8]); System.out.println(intArr[9]); However, as you can see, if you have a lot of elements then it isn't the best idea to deal with them like that. In that case, you'll use a loop, especially when you've no idea how many elements you'll have. You can simplify the above into just a couple lines: for(int i = 0; i < intArr.length; ++i){ System.out.println(intArr[i]); } ^See how that's a lot easier? https://code.sololearn.com/cEo0zUQSQ4eq/#java
10th Nov 2017, 5:02 PM
AgentSmith
+ 9
Totally misunderstood the question, thanks for the clarification @Netkos Ent :)
10th Nov 2017, 5:06 PM
Dev
Dev - avatar
+ 5
thinks,
10th Nov 2017, 5:01 PM
$_Raf_Orlando
$_Raf_Orlando - avatar
+ 5
@dev, i talk about array not String
10th Nov 2017, 5:02 PM
$_Raf_Orlando
$_Raf_Orlando - avatar
+ 4
@Eva No problem. I updated my answer fully, so look at it again for additional information and means of handling this situation. Posted example so you could see it in action on Code Playground.
10th Nov 2017, 5:05 PM
AgentSmith
+ 3
@Dev Definitely bro. I understand how you thought that though, so no worries. lol
10th Nov 2017, 5:09 PM
AgentSmith
0
Try in eclipse
11th Nov 2017, 11:42 AM
yuhjn
0
use for each loop to display it in a simple different way. for(int x:intArr){ System.out.print(x);
11th Nov 2017, 2:32 PM
yaree