ching lam

Greenhorn
+ Follow
since Jun 03, 2011
ching likes ...
Firefox Browser
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by ching lam

this is just a school assignment. I learned java for 4 weeks only. hehe
We are in Beginning Java, right?


And I am given a drive programme

Car car1 = new Car("Toyota", "Camry");
Car car2 = new Car("Hyundai", "Santa Fe");
Car car3 = new Car("Ford", "Escape");
...
...
...
System.out.println("How many cars? " + Car.getCount());
...

In this case, I think I cant count objects in a loop. This make me believe that I should use a list (which I have not learned yet). **wired
And not just counting, I will need to do car2.setMake(make), car1.setModel(model). All in all, I have to able to access all objects.
12 years ago
my problem is I dont know how to create an new object in each loop without using list.

I cant say Car car(i) = new Car() to create car1, car2, car3 and so on.

Furthermore, I will need to count how many cars I have created, does this imply that I must use a list?


Please help.

Or just tell me it is impossible without using list
12 years ago
yup
12 years ago
Hi, I need some help.

Is it possible to create multiple objects in a while loop without using list/array?
Actually, I have not learned to use array...

Here is part of drive programme:

Car car1 = new Car("Toyota", "Camry");
Car car2 = new Car("Hyundai", "Santa Fe");
Car car3 = new Car("Ford", "Escape");

any hint on how I create the objects?

Thanks.
12 years ago