New to java and trying to figure out how to print out a specific word in a string array. E.g.
String[] myArray = {"bread", "milk", "sugar", "coffee"}
I want to just print out the second value of the array (we say milk, I know the array index starts at 0 but just for this example we will go with this). Any ideas how to do this. I tried the for loop but cant seem to get it going so if you guys have an example it would be appreciated.
I cant exactly just print out by using index number. I will give a more detailed approach on how i would like it to work... Say I have two arrays String[] Array1 = {"bread", "milk", "sugar", "coffee"} String[] Array2 = {"butter", "tea", "spoon", "cup"} So if I prompted any entry from array 1 e.g. bread (I would like it to print out something like butter then) so for each value in array1 i would like it to return the value at the same index in array2.