Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2006

Tip: Looking for answers? Try searching our database.

how to create a Stack of Int data type

Thread view: 
akira32.java.help - 29 Nov 2006 14:19 GMT
import java.util.Stack;

private Stack<String> m_stack_B=new Stack<String>();//the line is okay
private Stack<int> m_stack_A=new Stack<int>();//add the line,will
appear below error message

Exception in thread "main" java.lang.Error: Unresolved compilation
problem:

    at HanoiTower.main(HanoiTower.java:24)
Thomas Fritsch - 29 Nov 2006 15:11 GMT
> import java.util.Stack;
>
[quoted text clipped - 6 lines]
>
>       at HanoiTower.main(HanoiTower.java:24)

The generics syntax wants a class name (a subclass of Object) between <...>,
but "int" is a primitive type, not a subclass of Object.
You should therefore use
 Stack<Integer>
instead of
 Stack<int>

Signature

"Thomas:Fritsch$ops.de".replace(':', '.').replace('$', '@')



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.