LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-02-2003, 05:21 PM   #1
stephenk
LQ Newbie
 
Registered: May 2003
Posts: 13

Rep: Reputation: 0
Unhappy java newbie


I am writing a java program with arraylist

for (int i = 0; i < Width; i++) {
myRect.add(new MyRect(a,b,c,d,r,z));
z += 1;
}

for (int i = 0; i < myRect.size(); i++) {
MyRect m = (MyRect)myRect.get(i);
System.out.println(m);
}

what i am trying to do is creating a myRect class object, all of them have the same a,b,c,d,r, except z, each myRect class is increment by 1, however, when i will to println those values out
i got all my z's to be a same number. doesn't anyone know why and how to tackle it. thanks
 
Old 07-02-2003, 05:56 PM   #2
zmedico
Member
 
Registered: Feb 2002
Location: Mission Viejo, California, USA
Distribution: Gentoo
Posts: 707

Rep: Reputation: 30
Re: java newbie

Quote:
Originally posted by stephenk

for (int i = 0; i < Width; i++) {
myRect.add(new MyRect(a,b,c,d,r,z));
z += 1;
}
z going into the constuctor is "pass by value" so the bug must be inside class MyRect. Post that code if you can't find the bug.
 
Old 07-02-2003, 09:25 PM   #3
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
edited.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie question on java coolguy_iiit Programming 6 05-12-2005 12:47 PM
A very basic newbie question on Java lmellen Programming 5 07-19-2004 03:59 PM
newbie java question lmellen Programming 6 06-30-2004 04:34 PM
Java Newbie Question patpawlowski Programming 6 02-27-2004 04:25 PM
Linux Java Help newbie :( hendryx Linux - Newbie 4 09-23-2003 02:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration