Java School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a Java Expert!

Join 300,475 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,736 people online right now. Registration is fast and FREE... Join Now!




error symbol : constructor WWLTableModel() -->how to call a class

 

error symbol : constructor WWLTableModel() -->how to call a class, trying to call a class of different filename from main program (filena

nastassja_hong

13 Sep, 2007 - 02:04 PM
Post #1

New D.I.C Head
*

Joined: 13 Sep, 2007
Posts: 2


My Contributions
my main program is called SP.java with GUI and i created another class WWLTableModel.java. i would like to call the WWLTableModel class from my main program and i tried using the below codings

CODE

    private void createSetComparison (){
        WWLTableModel[] wwlTM = new WWLTableModel [map.size()]; //create a Set of array and store in WWLTableModel
        
        Set set1 = map.entrySet();
        Iterator iteratorSet1 = set1.iterator();
        int a = 0;
        
        
        while (iteratorSet1.hasNext()){
            wwlTM[a]= new WWLTableModel(); //-->error appears here
            
        }
        
    }


but there is an error on the code lined wwlTM[a]= new WWLTableModel(); after compilation, which says

symbol : constructor WWLTableModel()
location: class WWLTableModel
wwlTM[a]= new WWLTableModel();

how do i solve this problem?? in other words, how do i call the class WWLTableModel from my main program??

User is offlineProfile CardPM
+Quote Post


Martyr2

RE: Error Symbol : Constructor WWLTableModel() -->how To Call A Class

13 Sep, 2007 - 04:24 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 7,246



Thanked: 820 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
First of all make sure you have your class in the same directory as your main program (I don't think this is your real problem but it is just to make sure). Secondly, did you define constructors in your class? I am betting you did but you forgot to create a default constructor. Remember, if you chose to create constructors you must also define a default constructor if you intend to use one... which you are with the line you are using.

CODE

public class blah {
    public blah() { System.out.println("now works"); }
    public blah(int i) { System.out.println("Testing"); }
}


If I was to take out the default constructor I have defined above (the one that reads "now works") and then try to create a new object using the default constructor it would error out...

CODE

// Errors out if I only had blah(int i) defined and no default constructor.
blah myblah = new blah();


So go back and look at your class. I am sure you will find it missing a default constructor. Either put one in or back in your main program instead of using just new WWLTableModel(); use one of your constructors that takes parameters.

Hope this makes sense to you! smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 03:02AM

Live Java Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month