P
Peter Jones
I'm trying to generate an object name during run time, and then create an
object with the contents of that variable. You can see that I'm trying to
also make the object name self generating (almost, the 'y' variable isnt
being incremented yet), putting two values ('y' and 'C'). My apologies for
poor coding structure / lack of comments, but I'm am a bit lost on how to
work it out. MANY thanks in advance.Heres what I have so far:
public class testVariable
{
private String name = "";
private String New_name = "";
private int y = 2;
public testVariable()
{}
public void test(String x)
{
name = x;
New_name = name + y ;
System.out.println(New_name);
}
public String getNew_name()
{
return New_name;
}
public static void main(String[] args)
{
int z = 2;
testVariable Darren = new testVariable();
Darren.test("C");
testVariable "c"+ z = new testVariable();
String Old_name = New_name;
}
}
object with the contents of that variable. You can see that I'm trying to
also make the object name self generating (almost, the 'y' variable isnt
being incremented yet), putting two values ('y' and 'C'). My apologies for
poor coding structure / lack of comments, but I'm am a bit lost on how to
work it out. MANY thanks in advance.Heres what I have so far:
public class testVariable
{
private String name = "";
private String New_name = "";
private int y = 2;
public testVariable()
{}
public void test(String x)
{
name = x;
New_name = name + y ;
System.out.println(New_name);
}
public String getNew_name()
{
return New_name;
}
public static void main(String[] args)
{
int z = 2;
testVariable Darren = new testVariable();
Darren.test("C");
testVariable "c"+ z = new testVariable();
String Old_name = New_name;
}
}