Rose Marie
\wrapper
1 Answer(s)      2 years and 4 months ago
Posted in : Java Beginners

Hands on Exercise on Wrapper Class:

Write a Java code that converts integer to Integer converts Integer to String converts String to integer converts int to String converts String to Integer converts Integer to integer displays the largest and smallest values of type integer converts the decimal to binary and hexadecimal

expected output: String s = 26 Integer m = 26 String s = 26 String x = 6 integer m = 26 Integer.MIN_VALUE = -2147483648 Integer.MAX_VALUE = 2147483647 Binary: 11010 Hexadecimal: 1a

View Answers

January 27, 2011 at 12:29 PM


Hi Friend,

Try this:

class ConversionExample
{
    public static void main(String[] args) 
    {
     int i=26;
     Integer integer=new Integer(i);
     String st=integer.toString();
     int no=Integer.parseInt(st);
     String str=Integer.toString(no);
     Integer num=Integer.valueOf(str);
     int in=num.intValue();
     System.out.println("int to Integer= "+integer);
     System.out.println("Integer to String= "+st);
     System.out.println("String to int= "+no);
     System.out.println("int to String= "+str);
     System.out.println("Integer to String= "+st);
     System.out.println("String to Integer= "+num);
     System.out.println("Integer to int= "+in);
     int max=Integer.MAX_VALUE;
     int min=Integer.MIN_VALUE;
     System.out.println("Minimum value of integer: "+min);
     System.out.println("Maximum value of integer: "+max);
     System.out.println("Binary: "+Integer.toBinaryString(in));
     System.out.println("Hexadecimal: "+Integer.toHexString(in));

    }
}

Thanks









Related Pages:
\wrapper
\wrapper  Hands on Exercise on Wrapper Class: Write a Java code that converts integer to Integer converts Integer to String converts String to integer converts int to String converts String to Integer converts Integer
\wrapper
\wrapper  Hands on Exercise on Wrapper Class: Write a Java code that converts integer to Integer converts Integer to String converts String to integer converts int to String converts String to Integer converts Integer
\wrapper
\wrapper  Hands on Exercise on Wrapper Class: Write a Java code that converts integer to Integer converts Integer to String converts String to integer converts int to String converts String to Integer converts Integer
wrapper class
wrapper class  list wrapper class methods
wrapper class
wrapper class  wrapper class methods
wrapper class
wrapper class  why wrapper class does not have a default constructor
Wrapper
Wrapper       7.Wrapper This new wrapper interface provides a mechanism for accessing an instance of a resource. This is used by many JDBC driver implementations. Earlier the wrapper used to be data
wrapper classes
wrapper classes  Explain wrapper classes and their use?   Java Wrapper Class Wrapper class is a wrapper around a primitive data type... of the primitive wrapper classes in Java are immutable i.e. once assigned a value
Wrapper Class
Wrapper Class  what is wrapper class in java and why we use it   Hi Friend, Wrapper class is a wrapper around a primitive data type... of the primitive wrapper classes in Java are immutable i.e. once assigned a value to a wrapper
Wrapper
Wrapper       Java provides wrapper classes corresponding to each primitive data types in its "... utility methods to manipulate the values. All of the primitive wrapper classes
wrapper class.
wrapper class.  Write short note on character wrapper class.   Java Character Wrapper class The Character class wraps a value of the primitive type char in an object. An object of type Character contains a single field
Wrapper Class - Java Beginners
Wrapper Class  What is Wrapper class? Why are they use
Wrapper Class - Java Beginners
Wrapper Class  Please explain the above question on Wrapper class with some examples
Wrapper Classes
Primitive Wrapper Class In this section you will learn about Wrapper classes.... Wrapper class is a wrapper around a primitive data type. It represents... can be represented as a Boolean class instance. All of the primitive wrapper
java-wrapper class
java-wrapper class  dear people, may i know how to convert primitive data type into corresponding object using wrapper class with example please!!!   public class IntToIntegerExample { public static void
wrapper prob - Java Beginners
wrapper prob  Hello all Integer k = 128; Integer l = 128; System.out.println("k==l >> "+ (k==l)); Integer i = 127; Integer j = 127; System.out.println("i==j >> "+ (i==j)); Can anybody tell me that why
wrapper class concept
wrapper class concept  Write a Java class that stores an integer item id, a string item name and a float price. Store all these in a String member Variable, separated by a space delimiter. Use an overloaded method to add
Character Wrapper Class.
Character Wrapper Class.  what are Mirrored Unicode Characters?? and whats the use of "isMirrored(ch);method ??.where ch is any character argument..!!   Unicode is capable of representing many languages, including those
Wrapper Character class.
Wrapper Character class.  How do the methods 'isIndentifierIgnorable(ch)' and 'isISOControl(ch)' work?? while workin with 'Character' wrapper class..please tag a code too...   isIndentifierIgnorable(ch) method
Wrapper Classes
Wrapper Classes        In this section you will learn about Wrapper classes and all the methods that manipulate data and allows to operate a certain work. Wrapper class
Examples of Wrapper Class
Examples of Wrapper Class In this page we are giving you the links of tutorials on wrapper classes in Java. Wrapper classes are the classes present...) char 8) boolean Following are the example of wrapper classes in Java. 
write a program to demonstrate wrapper class and its methods......
write a program to demonstrate wrapper class and its methods......  write a program to demonstrate wrapper class and its methods
Use of wrapper objects - Java Interview Questions
Use of wrapper objects  What is the role & use of Java wrapper objects?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/wrapper-class/ Thanks
please tell me what is ment by wrapper class in java........
please tell me what is ment by wrapper class in java........  what is ment by wrapper class in java
Wrapper Class in Java
Wrapper Classes provide object methods for the eight primitive data types... data type, it can only be achieved by using Wrapper Classes in Java...) to an Object wrapper classes must be used. Wrapper classes are part of java.lang
Wrapper Class Tutorial and Examples
Wrapper Class Tutorial and Examples       Wrapper Classes   In this section you will learn about Wrapper classes and all the methods that manipulate
can we add primitive data to wrapper class object
can we add primitive data to wrapper class object  Hi, Here is my code: class Myclass{ public static void main(String args[]){ int i=2; Integer a= new Integer(3); a=a+i; System.out.println("a"+a); } } Thanks   Hello
write a program to evaluate the following investment equation make use of wrapper class v=p(1+r)rest to n
write a program to evaluate the following investment equation make use of wrapper class v=p(1+r)rest to n  write a program to evaluate the following investment equation make use of wrapper class v=p(1+r)rest to n
Integer exception in java
Integer exception in java       The integer class is a wrapper for integer value. Integers are not objects. The Java utility classes require the use of objects. If you
Autoboxing in Java
((int, float, double) into their corresponding Wrapper class object (Integer... he automatic transformation of wrapper class object into their corresponding... types into Wrapper class by Java compiler takes place when: a primitive data
Java Integer class
Java Integer class       Java provides wrapper classes corresponding to each primitive data types... wrapper object can be helpful in situations where only objects can be utilized
Autoboxing
and their corresponding object wrapper classes (eg, int and Integer, double and Double... the corresponding wrapper types, and are never slower. The immutability (can't be changed after creation) of the wrapper types may make it their use
java - Java Beginners
java   What is the difference between Wrapper Class and Vector Class
Java fundamentals
Java fundamentals  What are the ways to create Wrapper Objects
SME Server 7.0 Pre 2 has been released now
SME Server 7.0 Pre 2 has been released now SME Server 7.0 pre-release 2 is on its way to the mirrors, includes latest CentOS kernel and updates; reconfiguration reboot now requested after software installer updates; simple 'yum' wrapper
java - Java Beginners
java   What is the difference between Wrapper Class and Vector Class?  Hi Friend, Differences: Wrapper classes convert primitive data type to user defined data type. All the methods of the wrapper classes
java basics
java basics  What are wrapper classes?  When we need to store primitive datatypes as objects, we use wrapper classes. Wrapper class is a wrapper around a primitive data type. It represents primitive data types
java - JDBC
java  what is a wraperclass?  Hi friend, Wrapper class is a wrapper around a primitive data type. It represents primitive data types... as a Boolean class instance. All of the primitive wrapper classes in Java
core java - Java Interview Questions
core java  why sun soft people introduced wrapper classes? do we have any other means to achieve the functionality of what a Wrapper class provides.  Hi Friend, Wrapper classes make it easier to deal with primitives
assig
assig  use wrapper classes by implementing a program to calculate the percentage of marks in five courses of an MCA student
J2ee-Servlet
J2ee-Servlet  What is servlet wrapper class? Can u explain it. also send any link of Sun, so i can see the details
wrapperclasses
wrapperclasses  wrapper classes otherwise called as? what is the use of interfaces? How to minimize casting? Method is defination block or execution block
java - Java Interview Questions
java   All the wrapper classes (Integer, Boolean, Float, Short, Long... 4. extend java.lang.Number 5. are final   Hi friend, Wrapper class is a wrapper around a primitive data type. It represents primitive data
to know my answer
to know my answer  hi, this is pinki, i can't solve my question "how to change rupee to dollar,pound and viceversa using wrapper class in java." will u help me
JAVA - Java Beginners
JAVA  Simply explain about wrapper class & OOPS concept with example.   Hi friend, This is wrapper class code import java.io.*; public class WrapperClass { public static void main(String[] args) throws

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.