|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
conversion of Object into integer in JAVA Hi , I am java beginner. I was trying the conversion of Object into integer. Below java code which I have used for this: application.setAttribute("xyz",new Integer(5)); int total_Val=application.getAttribute("xyz"); //code to convert object into integer When I trying to execute this code I get error. Please help me to understand this conversion process if you can. |
#2
| |||
| |||
Re: conversion of Object into integer in JAVA Hello, I don't have very much knowedge, but have tried this type of conversion. I suggest you to try below code for the conversion object into integer: application.setAttribute("xyz",new Integer(5)); int total_Val=(Integer)application.getAttribute("xyz"); If you execute this code you will get the object in the integer type. I hope this clears your doubts. |
#3
| |||
| |||
Re: conversion of Object into integer in JAVA To convert object into integer, you should follow the below steps: 1. first you have to create the object 2. then convert object into string 3. and finally convert string into integer or float Code: int p =Integer.parseInt( object.toString() ); |
#4
| |||
| |||
Re: conversion of Object into integer in JAVA Please use below inbuild methods of java to convert object into integer or long or float: 1. toInt(java.lang.String pqr) // Converts the String object pqr to an int type. 2. toLong(java.lang.String pqr) //Converts the String object pqr to a long type. 3. toFloat(java.lang.String pqr) Converts the String object pqr to a float type. Last edited by Katty : 14-11-2009 at 12:48 PM. |
![]() |
|
Tags: conversion in java, conversion of object, java, object, object integer conversion, object into integer |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Java BigDecimal to Integer | Anthony12 | Software Development | 6 | 11-08-2010 05:09 PM |
integer to string conversion | cyber-noob | Software Development | 4 | 03-03-2010 10:26 PM |
How to convert Double data type value into Integer one in Java | Rover | Software Development | 4 | 25-09-2009 05:09 PM |
String veriable to stream object conversion? | Shashikant | Software Development | 2 | 02-02-2009 10:56 PM |
Object test = new Object() <-- Java, best way in C++ | ADISH | Software Development | 3 | 25-10-2008 02:32 PM |