java user input | java output | java output formatting

Опубликовано: 28 Май 2023
на канале: Smart Engineer
614
7

Follow me on Instagram
  / smart_engineer_youtube  

00:10 using scanner class
05:08 string input
07:12 next() and nextLine()
10:04 printing output
12:07 print formatted output

For taking user input use Scanner class inside java.util package. we need to import the package in order to use the Scanner class.
Create object of scanner class and by using the object we can access methods of scanner class.
for integer input use method nextInt()
for double input use method nextDouble()
for long input use method nextLong()
similarly for different input use corresponding next method

for string input we can use next() and nextLine() method
next() will read only one token
nextLine() will read entire line

for output we can use
print() - which will print whatever is there in the bracket
println() - will print things inside bracket and cursor moves to next line
printf() - will give formatted output

% [flags] [width] [.precision] conversion-character
eg: %-10.2s
flag can be +-0,
width will print the total length
precision - up to how many letters or digits we need
conversion character - s for string, d for digit , t for date

java input output tutorial
java user input
how to give user input in java
java output
java output formatting
how to get formatted output in java


На этой странице сайта вы можете посмотреть видео онлайн java user input | java output | java output formatting длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Smart Engineer 28 Май 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 614 раз и оно понравилось 7 зрителям. Приятного просмотра!