The console of my code shows
[Ljava.lang.String;@2a556333
Your name is [I@467aecef characters long.
That name sucks!
The problem is with the first 2 lines. The name of the boy/girl should appear on the first line and on the second line it should show the length of characters of that name. So the problem has to occur with the variables 'name' and 'lengthOfName' right? I'm using Eclipse and it doesn't show me any sources of error, so why is it showing random characters and how do I fix it?
Sidenote: I'm new here and wanted to know why the code space here doesn't include my imports and public classes within the gray spaces below? Or is this unnecessary?
For example: import java.util.Random; public class nameGenerator{
public static void main(String[] args){
String girlNames [] = {"Ava" , "Angelina" , "Mia" , "Samantha" , "Rose" , "Gabriella" , "Ronnie" , "Anegela" , "Asani" , "Sandy"};
String boyNames [] = {"John" , "Jayden" , "Jay" , "Bee" , "David" , "Mario" , "Chloe" , "Light" , "Sora",};
String description [] = { "Wonderfull name!" , "That name sucks!" , "A disgrace of a name" , "How could you name your child that?" , "Choose a different name that one is ugly. " };
String z = description[ new Random().nextInt(description.length)];
String x = boyNames[ new Random().nextInt(boyNames.length)];
String y = girlNames[ new Random().nextInt(girlNames.length)];
String name [] = {x,y};
int lengthOfName [] = {x.length(), y.length()};
System.out.println(name);
System.out.println("Your name is " + lengthOfName + " characters long.");
System.out.println(z);
}
}