Vectors? Why does this not work?

2002-01-10 Thread Rick Roberts

Why does this simple example not work?
I am using Tomcat 3.3 and JDK 1.3.1_01 and Redhat Linux 7.2

Thanks,

==

// SimpleClass.java
// A Simple Class
public class SimpleClass extends Object{
private static String last_name;
private static String first_name;
private static String middle_name;

// Constructor
public SimpleClass() {
this.last_name = null;
this.first_name = null;
this.middle_name = null;
}

public void setLastName( String val ) {
this.last_name = val;
}

public String getLastName( ) {
return this.last_name;
}

public void setFirstName( String val ) {
this.first_name = val;
}

public String getFirstName( ) {
return this.first_name;
}

public void setMiddleName( String val ) {
this.middle_name = val;
}

public String getMiddleName( ) {
return this.middle_name;
}

public String getFullName( ) {
return this.last_name + (this.first_name == null ?  : ,  + 
this.first_name) + (this.middle_name == null ?  :   + this.middle_name);
}

}// class SimpleClass



// VectorTest.java
// A Simple Vector Test
import java.util.*;

import SimpleClass;

class VectorTest{

public static void main( String args[] ){
Vector v = new Vector();

String firstNames[] = {
George,
John,
Thomas,
James,
James,
John,
Andrew,
Martin,
William,
John,
James,
Zachary,
Millard,
Franklin,
James
};

String lastNames[] = {
Washington,
Adams,
Jefferson,
Madison,
Monroe,
Adams,
Jackson,
Buren,
Harrison,
Tyler,
Polk,
Taylor,
Filmore,
Pierce,
Buchanan
};

System.out.println( \nPut class in Vector. );
for( int i=0; i15; i++ ){
SimpleClass inClass = new SimpleClass();
inClass.setFirstName( firstNames[i] );
inClass.setLastName( lastNames[i] );
System.out.println( i + :  + inClass.getFullName() );
v.addElement( inClass );
}

System.out.println( \n\nRetrieve class from Vector. );
for( int i=0; i15; i++ ){
SimpleClass outClass = (SimpleClass)v.elementAt( i );
System.out.println( i + :  + outClass.getFullName() );
}

} //main()

}//class VectorTest
=

Here is my output:

[projects]# java VectorTest

Put class in Vector.
0: Washington, George
1: Adams, John
2: Jefferson, Thomas
3: Madison, James
4: Monroe, James
5: Adams, John
6: Jackson, Andrew
7: Buren, Martin
8: Harrison, William
9: Tyler, John
10: Polk, James
11: Taylor, Zachary
12: Filmore, Millard
13: Pierce, Franklin
14: Buchanan, James


Retrieve class from Vector.
0: Buchanan, James
1: Buchanan, James
2: Buchanan, James
3: Buchanan, James
4: Buchanan, James
5: Buchanan, James
6: Buchanan, James
7: Buchanan, James
8: Buchanan, James
9: Buchanan, James
10: Buchanan, James
11: Buchanan, James
12: Buchanan, James
13: Buchanan, James
14: Buchanan, James

-- 
***
* Rick Roberts*
* Advanced Information Technologies, Inc. *
***



--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




RE: Vectors? Why does this not work?

2002-01-10 Thread Randy Layman


First, you should take this question to another forum since this one
is about the Tomcat Servlet Container.

Second, you probably need to do some basic Java learning since this.

Third, you are using static variables to hold your names.

Randy


 -Original Message-
 From: Rick Roberts [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, January 10, 2002 3:50 PM
 To: Tomcat Users List
 Subject: Vectors? Why does this not work?
 
 
 Why does this simple example not work?
 I am using Tomcat 3.3 and JDK 1.3.1_01 and Redhat Linux 7.2
 
 Thanks,
 
 ==
 
 // SimpleClass.java
 // A Simple Class
 public class SimpleClass extends Object{
 private static String last_name;
 private static String first_name;
 private static String middle_name;
 
 // Constructor
 public SimpleClass() {
 this.last_name = null;
 this.first_name = null;
 this.middle_name = null;
 }
 
 public void setLastName( String val ) {
 this.last_name = val;
 }
 
 public String getLastName( ) {
 return this.last_name;
 }
 
 public void setFirstName( String val ) {
 this.first_name = val;
 }
 
 public String getFirstName( ) {
 return this.first_name;
 }
 
 public void setMiddleName( String val ) {
 this.middle_name = val;
 }
 
 public String getMiddleName( ) {
 return this.middle_name;
 }
 
 public String getFullName( ) {
 return this.last_name + (this.first_name == null ?  
 : ,  + 
 this.first_name) + (this.middle_name == null ?  :   + 
 this.middle_name);
 }
 
 }// class SimpleClass
 
 
 
 // VectorTest.java
 // A Simple Vector Test
 import java.util.*;
 
 import SimpleClass;
 
 class VectorTest{
 
 public static void main( String args[] ){
 Vector v = new Vector();
 
 String firstNames[] = {
 George,
 John,
 Thomas,
 James,
 James,
 John,
 Andrew,
 Martin,
 William,
 John,
 James,
 Zachary,
 Millard,
 Franklin,
 James
 };
 
 String lastNames[] = {
 Washington,
 Adams,
 Jefferson,
 Madison,
 Monroe,
 Adams,
 Jackson,
 Buren,
 Harrison,
 Tyler,
 Polk,
 Taylor,
 Filmore,
 Pierce,
 Buchanan
 };
 
 System.out.println( \nPut class in Vector. );
 for( int i=0; i15; i++ ){
 SimpleClass inClass = new SimpleClass();
 inClass.setFirstName( firstNames[i] );
 inClass.setLastName( lastNames[i] );
 System.out.println( i + :  + inClass.getFullName() );
 v.addElement( inClass );
 }
 
 System.out.println( \n\nRetrieve class from Vector. );
 for( int i=0; i15; i++ ){
 SimpleClass outClass = (SimpleClass)v.elementAt( i );
 System.out.println( i + :  + outClass.getFullName() );
 }
 
 } //main()
 
 }//class VectorTest
 =
 
 Here is my output:
 
 [projects]# java VectorTest
 
 Put class in Vector.
 0: Washington, George
 1: Adams, John
 2: Jefferson, Thomas
 3: Madison, James
 4: Monroe, James
 5: Adams, John
 6: Jackson, Andrew
 7: Buren, Martin
 8: Harrison, William
 9: Tyler, John
 10: Polk, James
 11: Taylor, Zachary
 12: Filmore, Millard
 13: Pierce, Franklin
 14: Buchanan, James
 
 
 Retrieve class from Vector.
 0: Buchanan, James
 1: Buchanan, James
 2: Buchanan, James
 3: Buchanan, James
 4: Buchanan, James
 5: Buchanan, James
 6: Buchanan, James
 7: Buchanan, James
 8: Buchanan, James
 9: Buchanan, James
 10: Buchanan, James
 11: Buchanan, James
 12: Buchanan, James
 13: Buchanan, James
 14: Buchanan, James
 
 -- 
 ***
 * Rick Roberts*
 * Advanced Information Technologies, Inc. *
 ***
 
 
 
 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]
 

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Vectors? Why does this not work?

2002-01-10 Thread Matt Egyhazy

it looks like your code is working just fine to me, its doing exactly what
you wrote it to do.  i suggest reading an introductory java book, the wrox
java2 book is ok.  and this is not the mailing list for these types of
questions.

matt
- Original Message -
From: Rick Roberts [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Thursday, January 10, 2002 3:49 PM
Subject: Vectors? Why does this not work?


 Why does this simple example not work?
 I am using Tomcat 3.3 and JDK 1.3.1_01 and Redhat Linux 7.2

 Thanks,

 ==

 // SimpleClass.java
 // A Simple Class
 public class SimpleClass extends Object{
 private static String last_name;
 private static String first_name;
 private static String middle_name;

 // Constructor
 public SimpleClass() {
 this.last_name = null;
 this.first_name = null;
 this.middle_name = null;
 }

 public void setLastName( String val ) {
 this.last_name = val;
 }

 public String getLastName( ) {
 return this.last_name;
 }

 public void setFirstName( String val ) {
 this.first_name = val;
 }

 public String getFirstName( ) {
 return this.first_name;
 }

 public void setMiddleName( String val ) {
 this.middle_name = val;
 }

 public String getMiddleName( ) {
 return this.middle_name;
 }

 public String getFullName( ) {
 return this.last_name + (this.first_name == null ?  : ,  +
 this.first_name) + (this.middle_name == null ?  :   +
this.middle_name);
 }

 }// class SimpleClass
 


 // VectorTest.java
 // A Simple Vector Test
 import java.util.*;

 import SimpleClass;

 class VectorTest{

 public static void main( String args[] ){
 Vector v = new Vector();

 String firstNames[] = {
 George,
 John,
 Thomas,
 James,
 James,
 John,
 Andrew,
 Martin,
 William,
 John,
 James,
 Zachary,
 Millard,
 Franklin,
 James
 };

 String lastNames[] = {
 Washington,
 Adams,
 Jefferson,
 Madison,
 Monroe,
 Adams,
 Jackson,
 Buren,
 Harrison,
 Tyler,
 Polk,
 Taylor,
 Filmore,
 Pierce,
 Buchanan
 };

 System.out.println( \nPut class in Vector. );
 for( int i=0; i15; i++ ){
 SimpleClass inClass = new SimpleClass();
 inClass.setFirstName( firstNames[i] );
 inClass.setLastName( lastNames[i] );
 System.out.println( i + :  + inClass.getFullName() );
 v.addElement( inClass );
 }

 System.out.println( \n\nRetrieve class from Vector. );
 for( int i=0; i15; i++ ){
 SimpleClass outClass = (SimpleClass)v.elementAt( i );
 System.out.println( i + :  + outClass.getFullName() );
 }

 } //main()

 }//class VectorTest
 =

 Here is my output:

 [projects]# java VectorTest

 Put class in Vector.
 0: Washington, George
 1: Adams, John
 2: Jefferson, Thomas
 3: Madison, James
 4: Monroe, James
 5: Adams, John
 6: Jackson, Andrew
 7: Buren, Martin
 8: Harrison, William
 9: Tyler, John
 10: Polk, James
 11: Taylor, Zachary
 12: Filmore, Millard
 13: Pierce, Franklin
 14: Buchanan, James


 Retrieve class from Vector.
 0: Buchanan, James
 1: Buchanan, James
 2: Buchanan, James
 3: Buchanan, James
 4: Buchanan, James
 5: Buchanan, James
 6: Buchanan, James
 7: Buchanan, James
 8: Buchanan, James
 9: Buchanan, James
 10: Buchanan, James
 11: Buchanan, James
 12: Buchanan, James
 13: Buchanan, James
 14: Buchanan, James

 --
 ***
 * Rick Roberts*
 * Advanced Information Technologies, Inc. *
 ***



 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Vectors? Why does this not work?

2002-01-10 Thread Ed Sesek

Rick,

You are declaring the fields last_name, first_name, and middle_name as
static so there is only one instance of each of those for your SimpleClass (no
matter how many objects of type SimpleClass you create).

Ed

Rick Roberts wrote:

 Why does this simple example not work?
 I am using Tomcat 3.3 and JDK 1.3.1_01 and Redhat Linux 7.2

 Thanks,

 ==

 // SimpleClass.java
 // A Simple Class
 public class SimpleClass extends Object{
 private static String last_name;
 private static String first_name;
 private static String middle_name;

 // Constructor
 public SimpleClass() {
 this.last_name = null;
 this.first_name = null;
 this.middle_name = null;
 }

 public void setLastName( String val ) {
 this.last_name = val;
 }

 public String getLastName( ) {
 return this.last_name;
 }

 public void setFirstName( String val ) {
 this.first_name = val;
 }

 public String getFirstName( ) {
 return this.first_name;
 }

 public void setMiddleName( String val ) {
 this.middle_name = val;
 }

 public String getMiddleName( ) {
 return this.middle_name;
 }

 public String getFullName( ) {
 return this.last_name + (this.first_name == null ?  : ,  +
 this.first_name) + (this.middle_name == null ?  :   + this.middle_name);
 }

 }// class SimpleClass
 

 // VectorTest.java
 // A Simple Vector Test
 import java.util.*;

 import SimpleClass;

 class VectorTest{

 public static void main( String args[] ){
 Vector v = new Vector();

 String firstNames[] = {
 George,
 John,
 Thomas,
 James,
 James,
 John,
 Andrew,
 Martin,
 William,
 John,
 James,
 Zachary,
 Millard,
 Franklin,
 James
 };

 String lastNames[] = {
 Washington,
 Adams,
 Jefferson,
 Madison,
 Monroe,
 Adams,
 Jackson,
 Buren,
 Harrison,
 Tyler,
 Polk,
 Taylor,
 Filmore,
 Pierce,
 Buchanan
 };

 System.out.println( \nPut class in Vector. );
 for( int i=0; i15; i++ ){
 SimpleClass inClass = new SimpleClass();
 inClass.setFirstName( firstNames[i] );
 inClass.setLastName( lastNames[i] );
 System.out.println( i + :  + inClass.getFullName() );
 v.addElement( inClass );
 }

 System.out.println( \n\nRetrieve class from Vector. );
 for( int i=0; i15; i++ ){
 SimpleClass outClass = (SimpleClass)v.elementAt( i );
 System.out.println( i + :  + outClass.getFullName() );
 }

 } //main()

 }//class VectorTest
 =

 Here is my output:

 [projects]# java VectorTest

 Put class in Vector.
 0: Washington, George
 1: Adams, John
 2: Jefferson, Thomas
 3: Madison, James
 4: Monroe, James
 5: Adams, John
 6: Jackson, Andrew
 7: Buren, Martin
 8: Harrison, William
 9: Tyler, John
 10: Polk, James
 11: Taylor, Zachary
 12: Filmore, Millard
 13: Pierce, Franklin
 14: Buchanan, James

 Retrieve class from Vector.
 0: Buchanan, James
 1: Buchanan, James
 2: Buchanan, James
 3: Buchanan, James
 4: Buchanan, James
 5: Buchanan, James
 6: Buchanan, James
 7: Buchanan, James
 8: Buchanan, James
 9: Buchanan, James
 10: Buchanan, James
 11: Buchanan, James
 12: Buchanan, James
 13: Buchanan, James
 14: Buchanan, James

 --
 ***
 * Rick Roberts*
 * Advanced Information Technologies, Inc. *
 ***

 --
 To unsubscribe:   mailto:[EMAIL PROTECTED]
 For additional commands: mailto:[EMAIL PROTECTED]
 Troubles with the list: mailto:[EMAIL PROTECTED]


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Vectors? Why does this not work?

2002-01-10 Thread Rick Roberts

 First, you should take this question to another forum since this one 
is about the Tomcat Servlet Container.

I'm actually building a bean for a Tomcat JSP app that I am working on. 
 I presented the code this way to simplify my description of the problem.

 Second, you probably need to do some basic Java learning since this.

I feel like an idiot.

 Third, you are using static variables to hold your names.

That is it
I looked at this for hours and never noticed static.

Basically:

1. I'm an idiot.
2. And you quickly pointed that out.
3. I'm grateful.

Thanks,
Rick



--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Vectors? Why does this not work?

2002-01-10 Thread Darrell Esau

On Thursday 10 January 2002 01:14 pm, you wrote:
 Basically:

 1. I'm an idiot.
 2. And you quickly pointed that out.
 3. I'm grateful.

Heheheheh.. don't be too hard on youself.. it wasn't all _that_ obvious.

:)

-- 
Darrell Esau
Software Engineer, Sun Microsystems
NetAdmin Development

--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]




Re: Vectors? Why does this not work?

2002-01-10 Thread Micael Padraig Og mac Grene

At 03:49 PM 1/10/02 -0500, you wrote:
Why does this simple example not work?
I am using Tomcat 3.3 and JDK 1.3.1_01 and Redhat Linux 7.2

Thanks,

==

// SimpleClass.java
// A Simple Class
public class SimpleClass extends Object{
private static String last_name;
private static String first_name;
private static String middle_name;


Must be a trick school assignment.  The member variables are static.

Take the static out of the first name only and you will get something 
like this.  Easy.  lol.

Garbage In
0: Washington, George
1: Adams, John
2: Jefferson, Thomas
3: Madison, James
4: Monroe, James
5: Adams, John
6: Jackson, Andrew
7: Buren, Martin
8: Harrison, William
9: Tyler, John
10: Polk, James
11: Taylor, Zachary
12: Filmore, Millard
13: Pierce, Franklin
14: Buchanan, James
Garbage Out
0: Buchanan, George
1: Buchanan, John
2: Buchanan, Thomas
3: Buchanan, James
4: Buchanan, James
5: Buchanan, John
6: Buchanan, Andrew
7: Buchanan, Martin
8: Buchanan, William
9: Buchanan, John
10: Buchanan, James
11: Buchanan, Zachary
12: Buchanan, Millard
13: Buchanan, Franklin
14: Buchanan, James


--
To unsubscribe:   mailto:[EMAIL PROTECTED]
For additional commands: mailto:[EMAIL PROTECTED]
Troubles with the list: mailto:[EMAIL PROTECTED]