Trying to create an array of a class

This is the first time ive tried to use an array so its not surprising im having trouble.
this is my program:
import java.util.*;
public class studentRecordDemo
     public static void main(String[] args)
          int studNum, index;
          System.out.println("Enter the number of students you wish to record");
          Scanner keyboard = new Scanner(System.in);
          studNum = keyboard.nextInt();
          studentRecord student[] = new studentRecord[studNum];
          for (index = 0; index < studNum; index++)
          {student[index].readInput();
          student[index].writeOutput();}
}And it lets me compile it but when i enter a number it gives me the error:
Exception in thread "main" java.lang.NullPointerException
at studentRecordDemo.main(studentRecordDemo.java:15)the
So yeah im trying to create an array of the class "studentRecord" and the number is input by the user. Is there a way to make that work or would it be easier to just make the array a really high number?

your error is in here:
student[index].readInput();its null...
This is the first time ive tried to use an array so
its not surprising im having trouble.
this is my program:
import java.util.*;
public class studentRecordDemo
     public static void main(String[] args)
          int studNum, index;
System.out.println("Enter the number of students
ts you wish to record");
          Scanner keyboard = new Scanner(System.in);
          studNum = keyboard.nextInt();
studentRecord student[] = new
ew studentRecord[studNum];
          for (index = 0; index < studNum; index++)
          {student[index].readInput();
          student[index].writeOutput();}
}And it lets me compile it but when i enter a number
it gives me the error:
Exception in thread "main"
java.lang.NullPointerException
at
studentRecordDemo.main(studentRecordDemo.java:15)the
So yeah im trying to create an array of the class
"studentRecord" and the number is input by the user.
Is there a way to make that work or would it be
easier to just make the array a really high number?

Similar Messages

  • I have trying to create an array of gpib instructions.

    The following is an example.
    Time           instruction               X                  Y              Z
    0 00:00:00,mot,v1_m1,-1492316.6919,-5204326.7860,3360431.4341,0,0,0,0,0,0,0,0,0,0,0
    The problem is I can create the time format column array but putting in the string command instruction in the second column is giving me problems.

    With an array, you cannot mix data types. Instead of a 2D numeric array, create a 1D cluster array. A cluster can have elements of different data types.

  • Trying to create and run my first class

    I am creating a simple class that should create a basic looking calculator type UI.
    When I try to build the program it builds successfully.
    However I get some null pointer exeption messages, and the GUI never appears.
    I am hoping that my problem is something simple.
    Any advice is appreciated.
    This is the class file:
    It will be followed by the main file.
    * CalculatorInterface.java
    * Created on: October 2, 2006, 10:43 AM
    * By: @author Administrator
    * Purpose: To create a Calculator GUI
    package Calculator;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    public class CalculatorInterface extends JFrame{
        private static final int WIDTH = 400;   //the width of the container
        private static final int HEIGHT = 400;  //the height of the container
        private JTextField numberTextField1, numberTextField2; //declare the text fields
        private JButton addB, subtractB, multiplyB, divideB; //declare the math buttons
        private JButton exitB; //declare the exit button
        private JLabel resultLabel;//declare result label
        private JPanel numbersPanel, buttonsPanel, resultsPanel;//declare panels
        private Container pane;//declare the container
        private GridLayout grid2by2, grid1by2;//declare the grids that will format buttonsPanel and numbersPanel
        private FlowLayout flowCenter;//declare the format for results panel
        private Toolkit aToolKit;//declare toolkit object used to get screen dimensions
        private Dimension screen;//declare variable used to hold screen dimensions
        private int xPositionOfFrame;//declare variable to hold the x position of frame
        private int yPositionOfFrame;//declare variable to hold the y position of frame
        private Formatter formatter;//declare formatter object to be applied to results
        /** Creates a new instance of CalculatorInterface */
        public CalculatorInterface() {
            setTitle( "Calculator" );//set title of frame
            setSize( WIDTH, HEIGHT );//set size of frame
            //instantiate JTextField objects
            numberTextField1 = new JTextField(5);
            numberTextField2 = new JTextField(5);
            //instantiate JButton Objects
            addB        = new JButton("+");
            subtractB   = new JButton("-");
            multiplyB   = new JButton("*");
            divideB     = new JButton("/");
            pane = getContentPane(); //instantiate the pane
            //instantiate the grid layouts
            grid1by2 = new GridLayout( 1, 2 );//grid for text fields
            grid2by2 = new GridLayout( 2, 2 );//grid for math buttons
            flowCenter = new FlowLayout();//to be applied to results pane
            //create the 3 panels
            buttonsPanel = new JPanel();
            numbersPanel = new JPanel();
            resultsPanel = new JPanel();
            //set layouts for panels
            buttonsPanel.setLayout( grid2by2 );
            numbersPanel.setLayout( grid1by2 );
            resultsPanel.setLayout( flowCenter );
            //add button fields to buttons panel
            buttonsPanel.add( addB );
            buttonsPanel.add( multiplyB );
            buttonsPanel.add( subtractB );
            buttonsPanel.add( divideB );
            //add text fields to numbers panel
            numbersPanel.add( numberTextField1 );
            numbersPanel.add( numberTextField2 );
            //add result label and exit button to results panel
            resultsPanel.add( resultLabel );
            resultsPanel.add( exitB );
            //add panels to content pane
            pane.add( numbersPanel, BorderLayout.WEST );
            pane.add( buttonsPanel, BorderLayout.EAST );
            pane.add( resultsPanel, BorderLayout.SOUTH );
    }This is the main file.
    * Main.java
    * Created: October 2, 2006, 10:41 AM
    * Author: Klinton Kerber
    * Purpose:To demonstrate knowledge gained in chapter 5
    *  by building a calculator that can add, subtract, divide,
    *  and multiply two numbers.
    package Calculator;
    import javax.swing.*;
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
        public static void main(String[] args) {
            JFrame aCalculatorGUI = new CalculatorInterface(); //create the GUI
            aCalculatorGUI.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            aCalculatorGUI.setVisible( true );
    }Thanks for the time.

    You read a stack trace from bottom up to get a chrnological list of events that led to the problem.
    The last line says that you were executing the main method in
    the Calculator.Main class. On line 26 of the file Main.java, the
    constructor of Calculator.CalculatorInterface was called (see line
    above the last one). <init> stands for constructor. On line 95 of
    CalculatorInterface.java, you called Container.add. As you can see,
    other calls follow. They are internal to the Java libraries, therefore
    not so relevant. You now know that the problem is on line 95 of
    CalculatorInterface.java. Why would a library method "crash"?
    Probably because you gave it a wrong parameter as explained in the
    other answer.

  • Creating an array of objects

    Hey,
    I basically have two classes and am trying to create an array of one class in the sub class. My code keeps coming up with <identifier> expected on complie:
    Main Class
    import java.util.ArrayList;
    import java.io.*;
    * @author David Bainbridge
    * @Date 12/02/07
    public class Main {
             public ArrayList<City>ListOfCities;
    public static void main(String[] arguments) {
         Main.newcity();
         public Main() {
         ListOfCities = new ArrayList<City>(); //this creates an array which stores all instances of the cities.
         public static void newcity() {
              String Name = "Lincoln";
              String Lat = "10";
              String Long = "11";         
              ListOfCities.add(new City(Name, Lat, Long)); 
              Lincoln.displaycity();
    }City Class
      * The City class represents a City.
      * @author David Bainbridge
      * @Date 13/02/07
    public class City {
         private String Name;
         private String Latitude;
         private String Longitude;
          * Constructor for the City.
         public City(String cityName, String cityLat, String cityLong) {
              Name = cityName;
              Latitude = cityLat;
              Longitude = cityLong;          
          * Display the current City.
    public void displaycity() {
              System.out.println("Name: " + Name);
              System.out.println("Latitude: " + Latitude);
              System.out.println("Longitude: " + Longitude);
    }

    Thanks JJCoolB but neither worked!
    I have rejigged my code:
    import java.util.ArrayList;
    import java.io.*;
    * @author David Bainbridge
    * @Date 12/02/07
    public class Main {
             public static ArrayList<City>ListOfCities;
    public static void main(String[] arguments) {
         ListOfCities = new ArrayList<City>(); //this creates an array which stores all instances of the cities.
         Main.newcity();
         public static void newcity() {
              String Name = "Lincoln";
              String Lat = "10";
              String Long = "11";         
              ListOfCities.add(new City(Name, Lat, Long)); 
              Lincoln.displaycity();
    }I get two complie errors with it one says:
    public static ArrayList<City>ListOfCities; - <identifier> expected
    ListOfCities = new ArrayList<City>(); //this creates an array which stores all instances of the cities. - '(' or '[' expected.
    Thanks in advance for any help people!

  • Creating an arrays of objects from a class

    I was wondering does any one know how to create an array of objects from a class?
    I am trying to create an array of objects of a class.
    class name ---> Class objectArray[100] = new Class;
    I cant seem to make a single class but i need to figure out how to create an array of objects.
    I can make a normal class with Class object = new Class

    There are four lines of code in your for-loop that actually do something:
    for(index = 0; index < rooms.length; index++) {
    /*1*/  assignWidth.setWidth(Double.parseDouble(in.readLine()));
    /*2*/  rooms[index] = assignWidth;
    /*3*/  assignLength.setWidth(Double.parseDouble(in.readLine());
    /*4*/  rooms[index] = assignLength;
    }1.) Sets the width of an object, that has been instantiated outside the loop.
    2.) assigns that object to the current position in the array
    3.) Sets the width of a second object that has been instantiated outside the loop
    4.) assigns that other object to the current position in the array
    btw.: I bet you meant "assignLength.setLength(Double.parseDouble(in.readLine());" in line 3 ;)
    Since each position in an array can only hold one value, the first assignment (line 2) is overwritten by the second assignment (line 4)
    When I said "construct a new room-object and assign it to rooms[index]" I meant something like this:
    for(index = 0; index < rooms.length; index++) {
        Room aNewRoom = new Room();
        aNewRoom.setWidth(Double.parseDouble(in.readLine()));
        aNewRoom.setLength(Double.parseDouble(in.readLine());
        rooms[index] = aNewRoom;
    }1.) Constructs a new Object in every iteration of the for-loop. (btw: I don't know what kind of objects you're using, so this needs most likely modification!!)
    2.) set the width of the newly created object
    3.) set the length of the newly created object
    4.) assign the newly created object to the current position in the array
    -T-
    btw. this would do the same:
    for(index = 0; index < rooms.length; index++) {
        rooms[index] = new Room();
        rooms[index].setWidth(Double.parseDouble(in.readLine()));
        rooms[index].setLength(Double.parseDouble(in.readLine());
    }but be sure you understand it. Your teacher most likely wants you to explain it ;)

  • Out of memory error when creating an array

    I'm trying to create 3D array of Bytes.
    Byte[][][] disk = disk = new Byte[11][9][25344];
    This is where I get an OutofMemory error.
    Please help!!!

    It is not as ballubadshah asserts a matter of how much memory you have but rather how much is allocated by default to the JVM heap.
    This number according to http://java.sun.com/docs/hotspot/ism.html is 64megabytes.
    When I run the following code, I get the number 64618496 which is just shy of 67108864, 64 meg. If I increase the array size I get the same error as you.
    To get past this, you can increase the heap size at runtime with the option -Xmx###m where ### is the number of megabytes to use for heap.
    ex
    c:/test>java -Xmx128m Memorypublic class Memory
       public static void main(String[] args)
          Runtime.getRuntime().gc();
          long start = Runtime.getRuntime().totalMemory();
          Byte[][][] bytes = new Byte[11][9][25344];
          for(int i = 0; i < 11; i++)
             for(int j = 0; j < 9; j++)
                for(int k = 0; k < 45344; k++)
                   bytes[i][j][k] =
                      new Byte(new Double(Math.random() * 256).byteValue());
          Runtime.getRuntime().gc();
          long end = Runtime.getRuntime().totalMemory();
          System.out.println("memory usage  = " + Long.toString(end - start));
    }

  • Problems creating an array and mixing them up

    I am trying to create an array (1-35), mix that array and display the results with a trace. I am getting an error withthe following code.
    public function generateArray(toNumber : int) : Array {
            var result : Array = [];
            for (var i : int = toNumber; i != 0; i--) {
            result.push(i);
            return result;
            public function shuffle (a:Array,i:int):Array
            {var rndm:int;
            var b:Array = a.slice();
            var c:Array = [];
            while (i) {
            rndm = Math.random() * b.length;
            c.push(b.splice(rndm,1)[0]);
            i--;
            return c;
             /*limit question display to 35*/
             generateArray(35);
             trace(generateArrays);
    the error(s) are:
    1180: Call to a possibly undefined method generateArray.
    1120: Access of undefined property generateArrays.
    please assist with resolving these problems.
    thanks in advance!

    generateArray(35) and that trace() must be inside a method (or methods).  for example,
        internal class Mixer {
            //retains the array that is consulted for random question numbers
            private var randomizedOrder:Array;
            //CONSTRUCTOR - passed total number of questions in section
            public function Mixer (questnsTotal:Number) {
                randomizedOrder = new Array();
                randomizedOrder[0] = Math.floor(Math.random()*questnsTotal);
                for (var i:Number=1; i<questnsTotal; i++) {
                    randomizedOrder[i] = newNumber(questnsTotal, i);
                for (var k:Number=0; k<questnsTotal; k++) {
                    trace(""+k+": "+randomizedOrder[k]);
      /*limit question display to 35*/
             generateArray(35);
             trace(generateArray);
            //recursive function that creates a new number until it creates one that isn't already in use
            private function newNumber (qTotal:Number, curNum:Number):Number {
                var newNum:Number = Math.floor(Math.random()*qTotal);
                for (var j:Number=0; j<curNum; j++) {
                    if (randomizedOrder[j] == newNum) {
                        return newNumber(qTotal, curNum);
                return newNum;
            public function generateArray(toNumber : int) : Array {
            var result : Array = [];
            for (var i : int = toNumber; i != 0; i--) {
            result.push(i);
            return result;
            public function shuffle (a:Array,i:int):Array
            {var rndm:int;
            var b:Array = a.slice();
            var c:Array = [];
            while (i) {
            rndm = Math.random() * b.length;
            c.push(b.splice(rndm,1)[0]);
            i--;
            return c;
            //This is how external classes acquire a random number from this class's array
            //(programNum = the question the program wants to ask next, based on sequential order, or user selection)
            internal function getRandomNumber(programNum:Number):Number {
                return randomizedOrder[programNum];

  • Help please! Using an array in another class

    Hello, I'm new to JAVA and I'm trying to pass an array from one class to another, but I can't get it right. I've been able to get individual values on at a time.
    If any one can help me out and give me a quick sample of how to do it,
    I've done this below.
    Is it as simple as an individual value - but just calling it an array - instead of say a string - or is it more complex. Please Help
    class BoxVol extends Box {
    public static void main (String args[]) {
    Box ob1 = new Box();
    int[] vol;
    ob1.getLength();
    vol = ob1.getLength();
    System.out.println("Volume is : " + vol);
    } class Box {
    // what are the properties or fields
         private int innerData [];
    //public String length2 = "text";
    // what are the actions or methods
    public void setLength(String p)
         innerData = new int [5];
         for (int i=0; i < innerData.length; i++)  {
              innerData = i;
    public int[] getLength()
         return innerData;

    Guss46 wrote:
    hmmm I see, I shouldve seen that last night when I was working on this....but I was very tired....
    I don't have a compiler in front of me now,
    would this solve my problem
    1st :
    ob1.getLength();
    //Should be....
    vol = ob1.getLength();
    No you are missing my point. You original code was calling the getLength method twice. On the first line it did nothing with the returned value and on the second you assigned the returned value to vol. But the setLength method is where you actually create the array and assign values to it. So unless you call that method first then you will not have an array at all.
    >
    2nd:
    System.out.println("Volume is : " + vol);
    should be
    System.out.println("Volume is : " + vol.length);
    Yes you could do that but all that will tell you is the length of the array and not what values are in it.
    .or vol[i] to go through it if I make a loop around it??Yep, sounds like a much better idea to me.

  • Creating special Array

    Hi, this is my first post here.
    I have been using Java for a few classes at Texas A&M and always seem to get stuck on the same and simplest steps in my programs.
    I have a program where input is taken from a file about students. Then information about students is assigned, and by user choices either sorted, displayed , searched and so on.
    I need to create an Array of students. so far the class layout of my code is this
    class Course{
    //set and get methods of grades and other information
    class Student{
    //set and get of student name and ID
    class groupOfStudents{
    //display information, read input file and keyboard input
    public Testing{
    main()
    I have to create an array of students and do things like
    for(int i = 0; i < MAXQUIZ; i++){
    student[1].setQuiz(i, Integer.parseInt(currentLine[3 + i]));
    there would be a higher for loop to go through all students, and the currentLine array is readLine().split(" ").
    I tried like Course[] student = new Course[numberOfStudents]; and other things of that sort, I bet this is a very simple idea but for some reason an array of non-primitive data types is hard for me because when I use new ClassName all I can see being run is the class constructor.
    Any help appreciated thanks :)
    null

    What I need is an array that is sort of like
    Student students[] = new Student[];
    I need an array of students with size
    numberOfStudents. You're almost there:
    Student students[] = new Student[numberOfStudents];
    Then for each student I will take
    the file input and call set functions for course
    information and student information.Well, I'd strongly avoid putting course information into objects that represent students. Rather, create course objects, and put pointers in your student objects to the course objects. Course details would go in course objects. The student class would have something like this in it:
    private Course[] courses;
    My main question really is how do you create an array
    of a non primative data type? Basically the above.
    How do you call on a
    class and create an array of that class...I've been
    doing it, and so far it seems to "work" but it tells
    me it can not see the methods in that class. for
    instance i'll tell the program...
    student[ i ].setQuiz(0, 100); and it tells me can not
    find method setQuiz(int, int) in class Course or
    Student, and what not and then I tried using extends
    (not very good with extends and interface usage).
    The method is there, correct spelling, correct type
    and number of arguments.Err..my guess is that you're not actually allocating the Student and Course objects, and you're getting NullPointerExceptions and that's confusing you. When you create an array of an object type, the values of the array are initially all null. You have to instantiate them yourself, like this:
    Student students = new Student[numberOfStudents];
    for(int i = 0; i < numberOfStudents; i++) {
        students[i] = new Student();
    }Except for one thing. It's generally a bad idea to create empty objects like that (new Student() without student info in them) and I'm guessing that you really don't know the number of students anyway until you read the file. So a better approach is usually to use a java.util.Collection subclass rather than an array, and then to add to it while you read the data file and create the Student objects on the fly, using data you read from the file.
    If this isn't your problem...then please post what you're trying to do (as short and simple as possible) and also the compiler error messages if it won't compile, or the stack traces if it will compile but not run. Wrap the code in [code][/code] tags when you post it.

  • Error while creating a overwrite method in class

    Hello.
    I'm trying to create an overwrite method in the class CL_HREIC_EECONTACT2SRCHV_IMPL but it just won't let me. Every time I try I get the message "The class has not yet been converted to the new class-local types" and I cannot create it.The thing is I've tried to create overwrite methods in diferent classes and sometimes I get the message and sometimes I don't, so it seems to depend on the class I'm trying to enhance, but I don't seem to be able to see any pattern in it.
    Any help?
    Thanks

    Hello i had the same problem and i couldn't create enhancement pre or post methods.
    The message was:
    The class has not yet been converted to the new class-local types
    Exception of class CX_ENH_OLD_LOCAL_CLASS_TYPES
    This can be fixed by entering in SE24 transaction: Change class. From menu choose: Utilities -> Convert class-local types.
    After that activate the class.
    Now the class can be enhanced.
    However this action requires change of the class
    Regards,
    Rosen

  • Creating multiple instances of a class in LabVIEW object-oriented programming

    How do you create multiple instances of a class in a loop?  Or am I thinking about this all wrong?
    For instance, I read in a file containing this information:
    Person Name #1
    Person Age #1
    Hobby #1
    Hobby #2
    Hobby #3
    Person Name #2
    Person Age #2
    Hobby #1
    Hobby #2
    Hobby #3
    Person Name #3
    Person Age #3
    Hobby #1
    Hobby #2
    Hobby #3
    If I define a Person class with name, age, and an array of strings (for the hobbies), how can I create several new Person instances in a loop while reading through the text file?
    FYI, new to LabVIEW OOP but familiar with Java OOP.  Thank you!

    First of all, let's get your terminology correct.  You are not creating multiple instances of a class.  You are creating Objects of the class.
    Use autoindexing to create an array of your class type.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Using an array in another class to set text of a button

    I am trying to use an array from one class in another to set the text of a button.
    This is the code in the class where i have made the array.
    public class EnterHomeTeam
         public int NumberOfPlayers = 11;
         public String[] PlayerName = new String [NumberOfPlayers];
    private void button1_Click (Object sender, System.EventArgs e)
              PlayerName [0] = this.HGoalKeeper.toString();
              PlayerName [1] = this.HDef1.toString();
              PlayerName [2] = this.HDef2.toString();
              PlayerName [3] = this.HDef3.toString();
              PlayerName [4] = this.HDef4.toString();
              PlayerName [5] = this.HMid1.toString();
              PlayerName [6] = this.HMid2.toString();
              PlayerName [7] = this.HMid3.toString();
              PlayerName [8] = this.HMid4.toString();
              PlayerName [9] = this.HAtt1.toString();
              PlayerName [10] = this.HAtt2.toString();     
              Players IM = new Players();
              this.Hide();
              IM.Show();
    }Then in the class where i want to use the variables (ie. PlayerName[0]) I have got
    public class Players
    EnterHomeTeam HT = new EnterHomeTeam();
    //and included in the button code
    this.button1.set_Text(HT.PlayerName[0]);I hope i have explained this well enough and hope someone can help me solve this problem! Im not a very competent programmer so i apologise if I havent explained this well enough!
    Adam

    .NET automatically generates quite a bit of code.... this is button1:
    private void InitializeComponent()
              this.button1 = new System.Windows.Forms.Button();
    // button1
              this.button1.set_BackColor(System.Drawing.Color.get_LightBlue());
              this.button1.set_Location(new System.Drawing.Point(88, 32));
              this.button1.set_Name("button1");
              this.button1.set_Size(new System.Drawing.Size(72, 56));
              this.button1.set_TabIndex(0);
              this.button1.set_Text(HT.PlayerName[0]);
              this.button1.add_Click( new System.EventHandler(this.button1_Click) );
    this.get_Controls().Add(this.button1);
         private void button1_Click (Object sender, System.EventArgs e)
              System.out.print(HT.PlayerName[0]);
              GKAction GK = new GKAction();
              this.Hide();
              GK.Show();
         }Hope that helps - im pretty sure that's all the button1 code

  • Array of generic class

    Hi.
    i have to create an array of generic class
    ex: GenericClass<E> [ ] x = new GenericClass<E>[ y ]
    is it possible?
    i can create GenericClass<E> [ ] x; but i can't initiate it in this way..
    Someone know how i can do it?

    crosspost
    http://forum.java.sun.com/thread.jspa?threadID=746524&messageID=4272614#4272614

  • Need help creating Vector table for specific class

    I am trying to create a Vector table of class Node and I think I understand the concept but in practice I am not
    sure why the compiler complains about non-static reference on statement mv.table.add(new Node(names[n]). Please help. I can not get this thing to work.
    import java.util.*;
    class MyVector {
    Vtable table;
    public static void main(String[] args){
    MyVector mv = new MyVector();
    String names[] = {"one","two","three","four","five"};
    for (int n;n<names.length;n++)
    mv.table.add(new Node(names[n])); //<-ERROR
    table.list();
    if (table.del("de")) System.out.println("deleted");
    table.list();
    public MyVector(){
    System.out.println("MyVector_C");
    table = new Vtable();
    public class Node {
    private String name;
    public Node(){name=new String("Null");}
    public Node(String s){name=s;}
    public void setName(String s){name=s;}
    public String getName(){return name;}
    public String toString(){return "[Node:"+name+"]";}
    public class Vtable extends Vector {
    private Vector v;
    public Vtable(){v=new Vector();}
    public void add(Node n){v.add(n);}
    public Node getNode(String s){
    Iterator i=v.iterator();
    while(i.hasNext()){
    Node n;
    n = (Node)i.next();
    if (s.equals((String)n.name))
    return(n);
    return null;
    public void list(){
    Iterator i=v.iterator();
    while (i.hasNext()){System.out.println((Node)i.next());}
    public Boolean del(String s) {
    Iterator i=v.iterator();
    while(i.hasNext()){
    Node n = (Node)i.next();
    if (s.equals((String)n.name)) {
    v.remove(n);
    return(true);
    return(false);
    }

    public class Vtable extends Vector {
    private Vector v;
    public Vtable(){v=new Vector();}
    public void add(Node n){v.add(n);}
    public Node getNode(String s){
    Iterator i=v.iterator();
    while(i.hasNext()){
    Node n;
    n = (Node)i.next();
    if (s.equals((String)n.name))
    return(n);
    return null;
    I get ur problem...
    When VTable extends Vector all u have to do is...
    VTable table=new VTable();
    table.add(new node(..));
    There is no need to get the Vector obj in picture as VTable extends Vector...
    I guess, this helps u.

  • Creating many arrays with different names

    I'm trying to create many arrays with a different names by calling this method:
    n=name of array
    c= some string
    public Array[] newArray(String n, String c)
    n[n.length]= new String();
    n[n.length]= c;
    As you experts might guess this does not compile. Is it even possible to do this?

    no, you cannot make a dynamic variable like that.
    and no, that is not the way to make arrays.
    and no, there is no such thing as "Array[]" ( unless u have made an "Array" object ).
    code for a new array is as such
    public Object[] newArray(int size){
      return new Object[size];
    }called as such:
    String[] strings = (String[]) newArray(10);
    strings[0] = "hmmm";mmmmm

Maybe you are looking for