The Artima Developer Community
Sponsored Link

Java Answers Forum
Please help me with this list

3 replies on 1 page. Most recent reply: May 9, 2002 3:44 PM by Evgen

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Sairah

Posts: 2
Nickname: javanovice
Registered: May, 2002

Please help me with this list Posted: May 7, 2002 10:05 AM
Reply to this message Reply
Advertisement
I am new to Java and I have to create a class called MyList that represents a list of maximum 20 items. The class should contain 2 data fields:
1. theData of type Vector for storing the elements of the list
2.maxElements of type int for storing the maximum size of the list.

I have a test file that will test to see if my list is working fine and give the results needed when any queries are made to it. However, I keep getting an error message about the constructor for the class MyList. Here is the start of my source code, which contains the error. If anyone wants to help with the rest later I'd be happy to show them what I've done for the methods of the list:


import java.util.Vector;

public class MylList {

public MyList (int m) {
aList = new Vector();
aList.setSize (20);
maxElements = m;}

private Vector aList;
private int maxElements;


Stefan Parijs

Posts: 16
Nickname: stefan
Registered: May, 2002

Re: Please help me with this list Posted: May 9, 2002 3:20 AM
Reply to this message Reply
1. theData of type Vector for storing the elements of the list
2.maxElements of type int for storing the maximum size of the list.

import java.util.Vector;
public class MylList
{
private Vector aList;
private int maxElements;

public MyList (int m)
{
aList = new Vector(20);
maxElements = m;
}

I don't know what was wrong with it, but, You als o can do this. If you want, you can send me your class: parijs_stefan@yahoo.com Then I watch it. And see what I can do.

Stefan

Stefan Parijs

Posts: 16
Nickname: stefan
Registered: May, 2002

Re: Please help me with this list Posted: May 9, 2002 3:21 AM
Reply to this message Reply
http://java.sun.com/products/jdk/1.4/docs/api/index.html

This is the url, of the online help from Sun. It is easy to understand.
Stefan

Evgen

Posts: 14
Nickname: evgen79
Registered: May, 2002

Re: Please help me with this list Posted: May 9, 2002 3:44 PM
Reply to this message Reply
What error message you keep getting?
May be "invalid method declaration; return type required", if that true than check name of class and name of constructor.

Flat View: This topic has 3 replies on 1 page
Topic: array of bytes.. Previous Topic   Next Topic Topic: Export sql to Excel

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use