ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
The GuestID is get from the text file, so GuestID is String. Now, i would like to set the GuestID in Guest.java. The problem is the GuestID in a.java is String but in Guest.java is Integer, so may i know how to convert String to Integer in java?
If you actually want to create an Integer object from a string (i.e. an object of class Integer, rather than a normal int), then you can use the Integer constructor that takes a string:
Integer i = new Integer("2");
If you just want to get the integer from the string into a "normal" int variable, then use the parseInt method of the Integer class:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.