I want to take input of a String and a int in one line and print the int in the output. For example, if user gives Boston 123, the output will show 123 only.

How to do this?

asked 22 May '17, 15:33

Omar's gravatar image

Omar
353


আপনি এইভাবে করতে পারেন ।

    Scanner sc = new Scanner("Name 20 3.5");

    String name = sc.next();
    int age = sc.nextInt();
    double gpa = sc.nextDouble();

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

    sc.close();

ধন্যবাদ :)

permanent link

answered 22 May '17, 17:17

menon's gravatar image

menon
4.1k222

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×203
×198

question asked: 22 May '17, 15:33

question was seen: 147 times

last updated: 22 May '17, 17:17