0
Java make array with elements of different type
e.g. {"nope", 5}
9 Answers
+ 4
An array with different types is not possible, but you can use a string array.
String [] str = {"nope", "5"}
//nope and 5 are frome type string --> to convert string to int:
int x = Integer.valueOf (str [1]) or int x = Integer.parseInt (str [1])
//x = 5
+ 2
Int [][] = { {1,2,3}, {4,5,6} }
An array with two arrays inside from type integer.
+ 2
CallMe Zitro Your welcome:
And if you want to store words in the first and numbers in the second array, you have to use string
String[][] example = { {"name", "age"}, {"23","10"} }
+ 1
Thank you for your answer! I really appreciate that!
+ 1
Thank you for your feedback!
0
Okay, and what if one element is array, and another is int?
0
Something like in the js
0
I have already passed this course, but haven't remembered that)