![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to decode string to integer
The method Integer.decode() decodes a string to an integer. It returns an Integer object holding the int value represented by the passed string value.
Note − It accepts decimal, hexadecimal, and octal number.
Let’s say the following is our string.
String val = "2";
The following is how you can decode the string to integer.
Integer myInt = Integer.decode(val);
Example
public class Demo { public static void main(String []args) { String val = "2"; Integer myInt = Integer.decode(val); System.out.println("Integer = " + myInt); } }
Output
Integer = 2
Advertisements