Getting input from user in java

preview_player
Показать описание
Java tutorial for beginners playlist

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

In this video we will discuss
1. Understanding java packages
2. Taking input from user
3. Streams
4. Scanner

Streams
1. Streams are objects representing source or destination of data
2. They are ordered sequence of bytes (length undefined)

Scanner
1. Breaks the input into tokens using a delimiter
2. Simple text scanner that can parse primitive types + Strings
3. Delimiter is whitespace by default
4. Possible to set delimiter using useDelimiter function

public String next() - Returns the next token
public String nextLine() - Returns the next line as a String
public byte nextByte() - Returns the next token as byte
public int nextInt() - Returns the next token as integer
public short nextShort() - Returns the next token as short
Рекомендации по теме
Комментарии
Автор

Plz dont forget to hit the like button if U like it.

raqibul
Автор

Hey Kudevenkat. I am doing a web/software development apprenticeship. What videos would you recommend for learning C#?

alritedave
Автор

Sir when we input name after the age..It does not take..it just moves to the next line ..why?

avlokanmohan
Автор

what is the need of a separate "err" stream in java?

dheerpandey
Автор

hello dear sir, i have some problem with this : i have a long number that i used BigInteger to define it and it's ok, but the thing is that i need to enter a part of that number using the scanner, so it will be like this so the 12 X's will be entered using the scanner and they will be put as a((part ))this number not multiplied by it < then i'll take the modulus of the whole number, please is there anyway so i can enter the 12X's inside that number in java??? appreciate any help

IQ
Автор

package com.mohan;

import java.util.*;
public class Pattern{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);

System.out.println("Enter your age ");
int age=sc.nextInt();

System.out.println("Enter your name ");
String name=sc.nextLine();

System.out.println("Enter your income");
double income=sc.nextDouble();

System.out.println(age);
System.out.println(name);
System.out.println(income);

}
}

avlokanmohan