How to use a Scanner in Netbeans - Java tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Thanks a lot!
I was having trouble because other places said to use java.util.Scanner which didn't work, and didn't give good examples and where to type and how to use scanners. Awesome job.

InFamousStickFigure
Автор

Nice one I loved the way you explained it! It wasn't boring at all Thanks 😊

shagunjan
Автор

thank you you have helped me not have to take exams for computer science in high school

airsoftg.i.operator
Автор

0:24 i love how he chuckles cause it says ass. A true man of culture

oscareditedthis
Автор

Thanks - Were following MOOC and stuck on this one since the auto translate machine stop for some reason

brothercoconut
Автор

I'm just wondering why you don't need to type sc.close(); to close your scanner incase of memory leaks. Is it just Netbeans not checking for that? I know in Drjava you get an error if you do not type sc.close();

christopherzhang
Автор

i have a soft error where it won't allow me to input, the input

shwiftymemelord
Автор

I have the exact same code as you and the program throws and exception: "input, please =>Exception in thread "main" No line found"


It doesn't pause to let me write, like it runs everything at once so it has no input and throws this exception. Help please

PatoAnastacio
Автор

Does this work for eclipse? Im sure the import is different but the rest is the same?

grimjudge
Автор


The reason you see the parse lines is because the scanner in this particular instance can only take a string as the variable type. Well, in order to format it, I have to have a double variable type. So, we use the parse tool to check it for numbers and save them into a new variable, that I then formatted! Check out the video here for another look at the parse tool:

NetbeansTutorials
Автор

Vielen Dank
Ich habe hundred mal versucht und hat nicht geklappt, jetzt aber hat es geklappt

MZ-tzbt
Автор

I want to learn about if and ifelse in scanner class

kiranjeetkaur
Автор

Can you please how to cutstring in java netbean ?

sophayon
Автор

My program not working it only do loadings not show output

Rohiit
Автор

What's output than you be completely

ansarihakimofficial
Автор

import java.text.DecimalFormat;

import java.util.*;

public class BlankPaper {
static DecimalFormat j = new DecimalFormat("$#, ###.##");
public static void main(String[] args) {

Scanner sc = new Scanner( System.in );

System.out.println("What's the number you want to format?");

System.out.println("Input please: -->");
String number = sc.nextLine();

double numberParsed = Double.parseDouble(number);

System.out.println("The formatted number is:"+j.format(numberParsed));




}

}


NetbeansTutorials
Автор

So I came up with an error on this line:
       Scanner sc = new Scanner(System.in);
This is the error code that popped up:
       constructor Scanner in class Scanner cannot be applied to given types;
       required: no arguments
       found: InputStream
       reason: actual and formal argument lists differ in length
I've double and triple checked my code and everything but the class name is exactly the same as your code in the video.  Please help, Thanks.

spencerkeehn
Автор

Task :run FAILED
what is your name:
input please:
Exception in thread "main" No line found
at
at

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.


BUILD FAILED in 346ms
2 actionable tasks: 2 executed



I KEEP GETTING THIS CAN YOU PLEASE HELP
I CAN'T INPUT ANYTHING

IR