BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Java Integer intValue() Method

By Chaitanya Singh | Filed Under: java

The intValue() method of Integer class returns the value of this Integer object as int. You can use this method for Integer to int conversion.

Syntax of intValue() method

public int intValue()

intValue() Parameters

NA

intValue() Return Value

  • Returns the value represented by Integer object as int primitive data type.

Example 1

A value contained by Integer object is converted into an int primitive data type using intValue() method.

class JavaExample {
  public static void main(String args[]) {
    Integer iObj = new Integer(33);
    //This method is called using Integer object
    //and returns an equivalent int value
    int iNum = iObj.intValue();
    System.out.println("Integer to int: "+iNum);
  }
}

Output:

Integer intValue method Output1

Example 2

The given string contains an integer value. This string is converted into an Integer object using Integer.valueOf() method and then the obtained Integer object is converted into an int using intValue() method.

class JavaExample {
  public static void main(String args[]) {
    String s = "123456";
    Integer iObj = Integer.valueOf(s);
    System.out.println("Integer object value: "+iObj);
    int iNum = iObj.intValue();
    System.out.println("int value: "+iNum);
  }
}

Output:

Integer intValue in Java Output2

Related guides:

  • Java Integer min()
  • Java Integer max()
  • Java Integer lowestOneBit()
  • Java String to int Conversion
  • Java Wrapper Class Tutorial
❮ Java Integer

Java Tutorial

Java Introduction

  • Java Index
  • Java Introduction
  • History of Java
  • Features of Java
  • C++ vs Java
  • JDK vs JRE vs JVM
  • JVM - Java Virtual Machine
  • First Java Program
  • Variables
  • Data Types
  • Operators

Java Flow Control

  • Java If-else
  • Java Switch-Case
  • Java For loop
  • Java while loop
  • Java do-while loop
  • Continue statement
  • break statement

Java Arrays

  • Java Arrays

OOPs Concepts

  • OOPs Concepts
  • Constructor
  • Java String
  • Static keyword
  • Inheritance
  • Types of inheritance
  • Aggregation
  • Association
  • Super Keyword
  • Method overloading
  • Method overriding
  • Overloading vs Overriding
  • Polymorphism
  • Types of polymorphism
  • Static and dynamic binding
  • Abstract class and methods
  • Interface
  • Abstract class vs interface
  • Encapsulation
  • Packages
  • Access modifiers
  • Garbage Collection
  • Inner classes
  • Static import
  • Static constructor

Java Exception Handling

  • Exception handling
  • Java try-catch
  • Java throw
  • Java throws
  • Checked and Unchecked Exceptions
  • Jav try catch finally
  • Exception Examples
  • Exception Propagation

Collections Framework

  • Collections in Java
  • Java ArrayList
  • Java LinkedList
  • Java Vector
  • Java HashSet
  • Java LinkedHashSet
  • Java TreeSet
  • Java HashMap
  • Java TreeMap
  • Java LinkedHashMap
  • Java Queue
  • Java PriorityQueue
  • Java Deque
  • Comparable interface
  • Comparator interface
  • Collections Interview Questions

MORE ...

  • Java Scanner Class
  • Java 8 Features
  • Java 9 Features
  • Java Conversion
  • Java Date
  • Java Multithreading
  • Java I/O
  • Java Serialization
  • Java Regex
  • Java AWT
  • Java Swing
  • Java Enum
  • Java Annotations
  • Java main method
  • Java Interview Q

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap