• Post Reply Bookmark Topic Watch Topic
  • New Topic

The constructor List(String) is undefine  RSS feed

 
Akmal Zahdi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiii every body, at the moment I still try make my hand dirty with java code. Actually I'm now practice code provide by this web site. It's Code Barn. Now, I'm doing tutorial "HelloThreadTwo" code. There is some error at there, I check it so many times but still not find the solution for this error. The error is "the constructor List(String) is undefine". The statement that make error is this statement:

myList = new List("Thread info goes here");

I think I already define it on the top like provided example.
The statement that define the constructor is :

private List myList;

Can anybody explain me about this. Is it my error or the code provide by this web site wrong. That's all from me. Tq.
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct the java.awt.List class does not have a constructor that takes in a String.

You should replace this line with

myList = new List();

It should fix that compile error.
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then call add method to add a string:

myList.add("Thread info goes here")
 
Akmal Zahdi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Manual Moon and KJ Reddy.
After I modify the code what u're ask me to write.

Then some error happen ..the statement make error is

myList.addItem( Thread.currentThread().getName() + " is running" );

and

myList.addItem( Thread.currentThread().getName() + " is done" );

I discard word Item....It's running.

I wonder Is it good for me to follow up the tutorial in there. I hope the admin for this site double check the provided tutorial here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!