Concatenation with integers & strings
719965Sep 21 2008 — edited Sep 21 2008I am new to java and was wondering how to concatenate strings with integers. Do I need to first change an int to its character value before concatenating it with a string? Most of the languages I have used will convert types automatically, but I'm new to Java.
I am trying to set up a for/next loop to allow the user to input student names for the grade book.
I have defined Student1Name, Student2Name, and Student3Name as strings.
I have also created a Scanner object:
Scanner inputStudent = new Scanner (System.in);
for (int i = 1; i < 4; i++)
{
System.out.print ("Please enter the name of student" + i + ": ");
"Student" + i + "Name" = inputStudent.nextLine();
}
Thank you for any help you can provide!
- Jeff C