Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 07-02-2003, 06:21 PM   #1
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);

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, 06:56 PM   #2
Registered: Feb 2002
Location: Mission Viejo, California, USA
Distribution: Gentoo
Posts: 707

Rep: Reputation: 30
Re: java newbie

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, 10:25 PM   #3
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:47 PM
A very basic newbie question on Java lmellen Programming 5 07-19-2004 04:59 PM
newbie java question lmellen Programming 6 06-30-2004 05:34 PM
Java Newbie Question patpawlowski Programming 6 02-27-2004 05:25 PM
Linux Java Help newbie :( hendryx Linux - Newbie 4 09-23-2003 03:28 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:14 AM.

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