![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 accept an integer from user and print it
Scanner class of the util package class is used to read data from user The nextInt() method of this class reads an integer from the user.
Program
import java.util.Scanner; public class PrintInteger { public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println("Enter an integer:"); int num = sc.nextInt(); System.out.print("Given integer is :: "+num); } }
Output
Enter an integer: 123 Given integer is :: 123
Advertisements