Creating an object during runtime
- From: Peter Jones <ant_on_line@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Nov 2005 21:50:19 +0000 (UTC)
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;
}
}
.
- Follow-Ups:
- Re: Creating an object during runtime
- From: zero
- Re: Creating an object during runtime
- From: Tjerk Wolterink
- Re: Creating an object during runtime
- Prev by Date: Re: checking casts
- Next by Date: Re: abstract class and method
- Previous by thread: abstract class and method
- Next by thread: Re: Creating an object during runtime
- Index(es):
Relevant Pages
|