Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 19th, 2005, 12:54 AM
Registered User
Join Date: Apr 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ruchilalla
Default typecasting int to java.lang.Integer

i want my result as a java,lang,Integer STORED in variable ITPAYABLE
as i am working with XMLBEANS


  public void perform1() throws Exception

        java.lang.Integer ITPAYABLE=calculate(GROSSINCOME);
private java.lang.Integer calculate(java.lang.Integer grossincome)throws Exception

        float f=10/100;
        String str=Float.toString(f);
        int i =Integer.parseInt(str);

      int a=(i*(grossincome.intValue()));

    return ITPAYABLE;

Old May 23rd, 2005, 06:11 AM
Authorized User
Join Date: Jul 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts

not entirely sure what the problem is, but I don't understand the code above. Not sure why you are trying to return ITPAYABLE from method calculate when surly the result is 'a'.

If you want to cast an int to an Integer you can just do

Integer objectInt = new Integer(5); etc

or in your case for your method:

return new Integer(a);

although a word on your code layout. It really is recommended that primitives and objects that are fully capitalized are only used for static final members of a class. i.e. constant values.

erm.. hope that's helpful.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Root Cause:java.lang.NoSuchMethodError: java.util. anees81 JSP Basics 3 March 1st, 2011 08:55 AM
java.lang.OutOfMemoryError: Java heap space meetkotresh J2EE 1 February 2nd, 2008 01:52 AM
java.lang.StackOverFlowError mrafeeq J2EE 1 August 10th, 2006 03:34 PM
java.lang.StackOverFlowError mrafeeq Pro Java 0 August 10th, 2006 12:51 PM
java.lang.ArrayIndexOutOfBoundsException chiraagb Pro JSP 1 July 1st, 2006 07:21 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.