0
Problem in code
I found this code on the internet and I was wondering why its not possible to simply modify array like: "String[] fruitOptions = {"Apple", "Apricot", "Banana" into for example:" int[] fruitOptions ={1,2,3}" How I would have to change this code to use integers instead of strings? link: https://www.thoughtco.com/example-java-code-for-building-a-simple-gui-application-2034066
7 Answers
+ 1
public class Program
{
public static void main(String[] args) {
int[] fruitOptions ={1,2,3};
System.out.print(fruitOptions[0]);
}
}
it does work.
Your problem might be related to the usage perhaps that combo box or whatever can't use an array of integers
0
in which language?
0
java
0
int[] fruitOption={1,2,3}
0
sorry i just typed it in here incorectly code is not working with or without the space doesnt matter
0
you end the line with ;
0
whole code is the same as in the link, all ; are on its place only thing changed is String for int and values in array