Results 1 to 5 of 5
- 03-24-2008, 07:11 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 2
- Rep Power
- 0
- 03-25-2008, 04:13 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
Which type of string you are talking about, a numeric one or not?
- 03-25-2008, 12:51 PM #3
Member
- Join Date
- Mar 2008
- Posts
- 2
- Rep Power
- 0
String Object.
- 03-25-2008, 01:15 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
Ok, you can't convert String object like "abcde" into int value. Only you can convert String objects like "123123" into int value.
So depend on that try to build your method.
Hope that what you expect.
- 03-25-2008, 01:16 PM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,370
- Blog Entries
- 1
- Rep Power
- 26
A code something like this may help to you.
Java Code:public void StringToInt(){ String charString = "Java"; // Try this for exception String numericString = "262"; try{ int intOfString = Integer.parseInt(numericString); // String should be numeric System.out.println(intOfString); } catch(NumberFormatException nfe){ System.out.println("NumberFormatException:" + nfe.getMessage()); } }
Similar Threads
-
How to write multiline String in a JLabel
By JavaBean in forum AWT / SwingReplies: 4Last Post: 12-14-2009, 06:09 AM -
How to write a java bean class object to XML file
By Java Tip in forum java.ioReplies: 0Last Post: 04-06-2008, 08:43 PM -
Object from String (calling method dynamically)
By Java Tip in forum Java TipReplies: 0Last Post: 02-16-2008, 10:22 PM -
String to Integer conversion
By eva in forum New To JavaReplies: 2Last Post: 12-17-2007, 04:59 PM -
How to cast an Object into a specific type (Integer/String) at runtime
By mailtogagan@gmail.com in forum Advanced JavaReplies: 2Last Post: 12-03-2007, 02:04 PM
Bookmarks