Contact Us
  
 
 
    SearchSearch   RegisterRegister   Log inLog in 

Convert Object into int

Convert Object into int

 
Post new topic   Reply to topic     Forum Index -> Java,Struts framework, Velocity, JSF, Hibernate, Servlet, JSP, javaBeans
View previous topic :: View next topic  
Author Message
juniormember



Joined: 28 Jun 2008
Posts: 154

PostPosted: Tue Nov 25, 2008 8:31 am    Post subject: Convert Object into int Reply with quote

Hi
I want to convert Object into int in java

I am using
code

application.setAttribute("ab",new Integer(5));

Now i want to
change it in int

int totalValue=application.getAttribute("ab");

if i do anything i get error of

Quote:
Can't convert java.lang.Object to int.


tell me how to convert an object into int in java
Back to top
View user's profile Send private message
seniormember
Site Admin


Joined: 20 Jul 2008
Posts: 77

PostPosted: Fri Dec 05, 2008 1:52 pm    Post subject: Reply with quote

Convert Object into int

try this
Code:

application.setAttribute("ab",new Integer(5));
int totalValue=(Integer)application.getAttribute("ab");


This can convert integer object to int
Back to top
View user's profile Send private message
ionut_g07



Joined: 15 Jul 2009
Posts: 1

PostPosted: Wed Jul 15, 2009 4:02 pm    Post subject: Object to int or double Reply with quote

try this:
Object object......
int i =Integer.parseInt( object.toString() );

so, you first convert objet to string the string to int or double...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Java,Struts framework, Velocity, JSF, Hibernate, Servlet, JSP, javaBeans All times are GMT
Page 1 of 1

 
Jump to:  
  Quick Post a Reply Topic
     
  Name (required)  
     
  Email Address (will not be published) (required)  
     
  Subject of topic (required)  
     
   
     
   
     
  Advertisement  
     
 
     


  More Links  
 
JSP Introduction
JSP Setup
Simple JSP Example
JSP Variable
Array Declaration in JSP
JSP Forms and User Input
Form Validation
JSP Cookies
JSP Session Object
Loop, content collection, iterator, conditional check in JSP
JSP Application Object
JSP Include
JSP Response Object
JSP Request Object
JSP Error Handling
JSP File Handling Object
JSP Action Tag
JSP Implicit Objects
JSP Declaration
JSP Directive
JDBC Introduction
JDBC Driver
JDBC Connection
JDBC Prepared/Statement
JDBC ResultSet
JDBC Close Connection object
JDBC Insert
JDBC Display Records
JDBC Update
JDBC Delete
JDBC Sorting
JDBC Query
JDBC Exception
JDBC Add Batch
JDBC Transaction/RollBack