RE: Bizzare bug with my class and sharing values between different instances

2004-08-09 Thread Shapira, Yoav

Hi,
In the future, please mark off-topic (i.e. not having to do with Tomcat,
which is the case with your general Java question) subjects as such by
prepending [OFF-TOPIC] to the subject line.  Thanks,

Yoav Shapira
Millennium Research Informatics


-Original Message-
From: Isen,Ciji [mailto:[EMAIL PROTECTED]
Sent: Friday, August 06, 2004 5:33 PM
To: Tomcat Users List
Subject: Re: Bizzare bug with my class and sharing values between
different
instances

I dont think a static member is what you wanted. What you seem to want
to is to store a data object.
That be the case there is no point making them static. remove the
static
key word in.

  private static int iNum;
  private static String sString;
and try.

Gig 'em,
Ciji Isen

ps: If you where to use an IDE like Eclipse or so I think it would have
suggested this as you write it.

Thomas Joseph Olaes wrote:

Hello, list!

I am currently busting my brain over this problem... I have the
following
class:

package net.olaes;

import java.lang.String;

public class NumAndString {
  private static int iNum;
  private static String sString;

  public NumAndString(int iNum, String sString){
this.iNum = iNum;
this.sString = sString;
  }

  public int getNum(){
return this.iNum;
  }

  public String getString(){
return this.sString;
  }
}

When I try to do the following in my JSP:

Vector v = new Vector();
v.add(new NumAndString(1, a));
v.add(new NumAndString(2, b));
v.add(new NumAndString(3, c));

Iterator i = v.iterator();
while(i.hasNext()){
  NumAndString nasThisOne = (NumAndString) i.next();
  out.println(nasThisOne.getNum());
  out.println(nasThisOne.getString());
}

I get:

3
c
3
c
3
c

I don't understand what I'm doing wrong, my gut says to check my class
definition, but I don't even know how to google up this problem
because I've never seen it before.

Anywho, I'll keep checking the net for my problem, but if anyone has a
quickie solution to my class up above, please help.

Thank you very much for your time and assistance in advance.

-TJ

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Bizzare bug with my class and sharing values between different instances

2004-08-06 Thread Benjamin Armintor
Your intended instance members are static.  That means that all
instances of the class share them.  That's not what you want.  

Benjamin J. Armintor
Operations Systems Specialist
ITS-Systems: Mainframe Group
University of Texas - Austin
tele: (512) 232-6562
email: [EMAIL PROTECTED]
 


-Original Message-
From: Thomas Joseph Olaes [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 06, 2004 4:05 PM
To: [EMAIL PROTECTED]
Subject: Bizzare bug with my class and sharing values between different
instances


Hello, list!

I am currently busting my brain over this problem... I have the
following class:

package net.olaes;

import java.lang.String;

public class NumAndString {
  private static int iNum;
  private static String sString;

  public NumAndString(int iNum, String sString){
this.iNum = iNum;
this.sString = sString;
  }

  public int getNum(){
return this.iNum;
  }

  public String getString(){
return this.sString;
  }
}

When I try to do the following in my JSP:

Vector v = new Vector();
v.add(new NumAndString(1, a));
v.add(new NumAndString(2, b));
v.add(new NumAndString(3, c));

Iterator i = v.iterator();
while(i.hasNext()){
  NumAndString nasThisOne = (NumAndString) i.next();
  out.println(nasThisOne.getNum());
  out.println(nasThisOne.getString());
}

I get:

3
c
3
c
3
c

I don't understand what I'm doing wrong, my gut says to check my class
definition, but I don't even know how to google up this problem because
I've never seen it before.

Anywho, I'll keep checking the net for my problem, but if anyone has a
quickie solution to my class up above, please help.

Thank you very much for your time and assistance in advance.

-TJ

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Bizzare bug with my class and sharing values between different instances

2004-08-06 Thread Robert Harper
The problem is that your data members are static. That means that for each
instance of the class, they all point to the same data member.

Robert S. Harper
801.265.8800 ex. 255
 -Original Message-
 From: Thomas Joseph Olaes [mailto:[EMAIL PROTECTED]
 Sent: Friday, August 06, 2004 3:05 PM
 To: [EMAIL PROTECTED]
 Subject: Bizzare bug with my class and sharing values between different
 instances
 
 Hello, list!
 
 I am currently busting my brain over this problem... I have the following
 class:
 
 package net.olaes;
 
 import java.lang.String;
 
 public class NumAndString {
   private static int iNum;
   private static String sString;
 
   public NumAndString(int iNum, String sString){
 this.iNum = iNum;
 this.sString = sString;
   }
 
   public int getNum(){
 return this.iNum;
   }
 
   public String getString(){
 return this.sString;
   }
 }
 
 When I try to do the following in my JSP:
 
 Vector v = new Vector();
 v.add(new NumAndString(1, a));
 v.add(new NumAndString(2, b));
 v.add(new NumAndString(3, c));
 
 Iterator i = v.iterator();
 while(i.hasNext()){
   NumAndString nasThisOne = (NumAndString) i.next();
   out.println(nasThisOne.getNum());
   out.println(nasThisOne.getString());
 }
 
 I get:
 
 3
 c
 3
 c
 3
 c
 
 I don't understand what I'm doing wrong, my gut says to check my class
 definition, but I don't even know how to google up this problem
 because I've never seen it before.
 
 Anywho, I'll keep checking the net for my problem, but if anyone has a
 quickie solution to my class up above, please help.
 
 Thank you very much for your time and assistance in advance.
 
 -TJ
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Bizzare bug with my class and sharing values between different instances

2004-08-06 Thread Filip Hanik - Dev
- remove the static keyword,

package net.olaes;

import java.lang.String;

public class NumAndString {
  private int iNum; //should NOT be static
  private String sString;

  public NumAndString(int iNum, String sString){
this.iNum = iNum;
this.sString = sString;
  }


- Original Message - 
From: Thomas Joseph Olaes [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, August 06, 2004 4:05 PM
Subject: Bizzare bug with my class and sharing values between different instances


Hello, list!

I am currently busting my brain over this problem... I have the following class:

package net.olaes;

import java.lang.String;

public class NumAndString {
  private static int iNum;
  private static String sString;

  public NumAndString(int iNum, String sString){
this.iNum = iNum;
this.sString = sString;
  }

  public int getNum(){
return this.iNum;
  }

  public String getString(){
return this.sString;
  }
}

When I try to do the following in my JSP:

Vector v = new Vector();
v.add(new NumAndString(1, a));
v.add(new NumAndString(2, b));
v.add(new NumAndString(3, c));

Iterator i = v.iterator();
while(i.hasNext()){
  NumAndString nasThisOne = (NumAndString) i.next();
  out.println(nasThisOne.getNum());
  out.println(nasThisOne.getString());
}

I get:

3
c
3
c
3
c

I don't understand what I'm doing wrong, my gut says to check my class
definition, but I don't even know how to google up this problem
because I've never seen it before.

Anywho, I'll keep checking the net for my problem, but if anyone has a
quickie solution to my class up above, please help.

Thank you very much for your time and assistance in advance.

-TJ

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Bizzare bug with my class and sharing values between different instances

2004-08-06 Thread Isen,Ciji
I dont think a static member is what you wanted. What you seem to want 
to is to store a data object.
That be the case there is no point making them static. remove the static 
key word in.

 private static int iNum;
 private static String sString;
and try.
Gig 'em,
Ciji Isen
ps: If you where to use an IDE like Eclipse or so I think it would have 
suggested this as you write it.

Thomas Joseph Olaes wrote:
Hello, list!
I am currently busting my brain over this problem... I have the following class:
package net.olaes;
import java.lang.String;
public class NumAndString {
 private static int iNum;
 private static String sString;
 public NumAndString(int iNum, String sString){
   this.iNum = iNum;
   this.sString = sString;
 }
 public int getNum(){
   return this.iNum;
 }
 public String getString(){
   return this.sString;
 }
}
When I try to do the following in my JSP:
Vector v = new Vector();
v.add(new NumAndString(1, a));
v.add(new NumAndString(2, b));
v.add(new NumAndString(3, c));
Iterator i = v.iterator();
while(i.hasNext()){
 NumAndString nasThisOne = (NumAndString) i.next();
 out.println(nasThisOne.getNum());
 out.println(nasThisOne.getString());
}
I get:
3
c
3
c
3
c
I don't understand what I'm doing wrong, my gut says to check my class
definition, but I don't even know how to google up this problem
because I've never seen it before.
Anywho, I'll keep checking the net for my problem, but if anyone has a
quickie solution to my class up above, please help.
Thank you very much for your time and assistance in advance.
-TJ
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Re: Bizzare bug with my class and sharing values between different instances

2004-08-06 Thread Thomas Joseph Olaes
Thanks alot everyone!

For some reason I thought I had to declare a class variable static so
the different functions inside would be able to access the variable.

-TJ

On Fri, 06 Aug 2004 16:32:40 -0500, Isen,Ciji [EMAIL PROTECTED] wrote:
 I dont think a static member is what you wanted. What you seem to want
 to is to store a data object.
 That be the case there is no point making them static. remove the static
 key word in.
 
   private static int iNum;
   private static String sString;
 and try.
 
 Gig 'em,
 Ciji Isen
 
 ps: If you where to use an IDE like Eclipse or so I think it would have
 suggested this as you write it.
 
 
 
 Thomas Joseph Olaes wrote:
 
 Hello, list!
 
 I am currently busting my brain over this problem... I have the following class:
 
 package net.olaes;
 
 import java.lang.String;
 
 public class NumAndString {
   private static int iNum;
   private static String sString;
 
   public NumAndString(int iNum, String sString){
 this.iNum = iNum;
 this.sString = sString;
   }
 
   public int getNum(){
 return this.iNum;
   }
 
   public String getString(){
 return this.sString;
   }
 }
 
 When I try to do the following in my JSP:
 
 Vector v = new Vector();
 v.add(new NumAndString(1, a));
 v.add(new NumAndString(2, b));
 v.add(new NumAndString(3, c));
 
 Iterator i = v.iterator();
 while(i.hasNext()){
   NumAndString nasThisOne = (NumAndString) i.next();
   out.println(nasThisOne.getNum());
   out.println(nasThisOne.getString());
 }
 
 I get:
 
 3
 c
 3
 c
 3
 c
 
 I don't understand what I'm doing wrong, my gut says to check my class
 definition, but I don't even know how to google up this problem
 because I've never seen it before.
 
 Anywho, I'll keep checking the net for my problem, but if anyone has a
 quickie solution to my class up above, please help.
 
 Thank you very much for your time and assistance in advance.
 
 -TJ
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Re: Bizzare bug with my class and sharing values between different instances

2004-08-06 Thread QM
On Fri, Aug 06, 2004 at 02:57:21PM -0700, Thomas Joseph Olaes wrote:
: For some reason I thought I had to declare a class variable static so
: the different functions inside would be able to access the variable.

Only if those methods themselves are static.

static data = class data = used in a static context
non-static data = (per-)object data = individual to the object

-QM

-- 

software  -- http://www.brandxdev.net
tech news -- http://www.RoarNetworX.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]