tashaunalewis3682 tashaunalewis3682
  • 01-09-2020
  • Computers and Technology
contestada

can java scanner not take in a negative input?

Respuesta :

MrRoyal
MrRoyal MrRoyal
  • 02-09-2020

Answer:

It can take a negative input

Explanation:

When you declare a variable in Java and you get your input via Scanner library; the Scanner library will accept the input irrespective of whether it's negative or not.

Take for instance, the following segment

Scanner input = new Scanner(System.in);

int userinput = input.nextInt()

Irrespective of whether userinput is negative or positive, it'll accept it.

Answer Link

Otras preguntas

a book sits at the top of a bookshelf is this question kinetic or potential energy
The volume of a prism is 230 mm3. Which statements are true about the same prism measured in cubic centimeters? Choose all answers that are correct. A. The num
Which statement explains why neon is a Group 18 element? (1) Neon is a gas at STP.(2) Neon has a low melting point. (3) Neon atoms have a stable valence electr
What is the empirical formula for a compound with the molecular formula C6H12Cl2O2? (1) CHClO (3) C3H6ClO (2) CH2ClO (4) C6H12Cl2O2
What is 8.83 rounded to?
Which statement accurately describes solids?
The key battle that finally turned the tide against the Confederates was the __________.
how many time does 4 go into 52
In Percy Bysshe Shelley's "Ozymandias," what effect is created by the poet's use of phrases like "antique land," "shattered visage," and "ye Mighty"? A. They i
How many centimeters are in 4.5 meters