0

Hey im trying to get a random output from a 2 Dimensional String Array but it keeps giving me the output "[Ljava.lang.String;@3fee733d"

public class VKSimple {

    public static void main(String[] args) {
        
    

           String[][] vk = {{"Hallo", "Hello"}, 
                            {"Haus", "House"}, 
                            {"Auto", "Car"}};
              
            Random r=new Random();        
            int randomNumber=r.nextInt(vk.length);
            System.out.println(vk[randomNumber]);
            
        }
    }

would appreciate if someone could help me

Graham
  • 1
  • 1
  • 1
    you aren't getting one string from the 2-d array, you are getting one of the inner arrays. That's why it's printing like that: `vk[]` *is itself an array* since `vk` is an array of arrays. – Esther Jun 21 '22 at 19:36
  • If you actually want the whole inner array, follow the link from @DanW 's comment. Otherwise, you need to randomly select one string from `vk[randomNumber]` and print *that*. – Esther Jun 21 '22 at 19:39
  • Yeah answerrd my question thank you @DanW – Graham Jun 21 '22 at 19:40

0 Answers0