Results 1 to 4 of 4
- 11-26-2007, 12:13 PM #1
Senior Member
- Join Date
- Nov 2007
- Posts
- 111
- Rep Power
- 0
Creating abjects with different names
Hi
I want to create objects of different names. Please check the code below:
Java Code:for(int i=0;i<noOfObject;i++) { System.out.println("Obj Created " + i); Student (obj+i) = new Student(); }
Java Code:Exception in thread "main" java.lang.Error: Unresolved compilation problem: The left-hand side of an assignment must be a variable
- 11-26-2007, 12:41 PM #2
Member
- Join Date
- Nov 2007
- Posts
- 8
- Rep Power
- 0
You cannot use (obj+i) to assign an new object. Try using array of objects instead. Something like :
obj[i] = new Student();
- 11-26-2007, 12:54 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
Yep, use obj[] within your object limit.
- 11-26-2007, 01:14 PM #4
Senior Member
- Join Date
- Nov 2007
- Posts
- 111
- Rep Power
- 0
Similar Threads
-
Names pipes in java
By Zept in forum NetworkingReplies: 2Last Post: 08-06-2011, 09:20 PM -
Getting method names using Reflection
By Java Tip in forum Java TipReplies: 0Last Post: 01-24-2008, 04:18 PM -
Getting names of table columns
By Java Tip in forum Java TipReplies: 0Last Post: 01-07-2008, 09:39 AM -
Drive names
By alwz_nikhil in forum New To JavaReplies: 0Last Post: 11-28-2007, 11:04 AM -
how to get the names of the files
By mary in forum Advanced JavaReplies: 2Last Post: 08-05-2007, 05:01 AM
Bookmarks