I need to create different strings inside a while loop, the problem is how to name them and not having them overwritten each time
for ex:

while (i<10)
{
String x=scan.nextLine(); //here is the problem, x gets overwritten each time
i++}

Thank you in advance.

Have you thought about using an array and a for loop? Then you could increment the index of the array for each string entered.

Seems that I will have to wait till I get to this chapter...
Thanks anyway.

Well, isn't there a way to use the value of a string to name another string?

for (int i=0;i<10;i++)
{
String s1="str";
i to string //transmute i to a string object
String s2=s1+i;
String x//instead of having a new name, just using the value of s2 (str0, str1, str2)
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.