The Artima Developer Community
Sponsored Link

Java Buzz Forum
Integer Wrapper class

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
Integer Wrapper class Posted: Jun 18, 2015 7:36 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: Integer Wrapper class
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement
  • Integer  class is present in java.lang package.
  • java.lang.Integer  is used to represent integer primitive value in form of object.

Class Definition

  1. public final class Integer
  2. extends Number 
  3. implements Comparable<Integer>

Integer Class Constructors

1.public Integer(int value):
  • It takes int primitive value as an argument.
Java code to convert int primitive to Integer object


  1. package com.instanceofjavatutorial;
  2.  
  3. public class IntegerDemo {
  4.  
  5. public static void main(String[] args) {
  6.  


  7.  Integer obj=new Integer (37);
  8.  
  9.  System.out.println(obj);
  10.  
  11.  
  12. }
  13. }

Output:
  1. 37

2.public Integer(String s)  throws NumberFormatException:

  • It takes String value as an argument. 

Java code to convert String to Integer object


  1. package com.instanceofjavatutorial;
  2.  
  3. public class IntegerDemo {
  4.  
  5. public static void main(String[] args) {
  6.  


  7.  Integer obj=new Integer ("123");
  8.  
  9.  System.out.println(obj);
  10.  
  11.  
  12. }
  13. }

Output:
  1. 123

Read: Integer Wrapper class

Topic: Deepening the hole metaphor Previous Topic   Next Topic Topic: Java Agents

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use