Questions tagged as 'scanner'

1
answer

Scanner.nextLine () does not act correctly after Scanner.nextInt ()

I have this code: Scanner scan = new Scanner(System.in); String s2 = scan.nextLine(); int i2 = scan.nextInt(); System.out.println("natural= " + i2); System.out.println("cadena = " + s2); scan.close(); That works correctly:    This...
asked by 02.09.2016 / 11:45
3
answers

How to enter data in the same line

How can I enter data on the same line? public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Introduce la hora"); int hora = sc.nextInt(); System.out.print(":"); int minutos = s...
asked by 20.09.2018 / 13:41
2
answers

Why does not the Scanner read the variables and sometimes send an exception?

I have the following problem: when running the program the menu is shown with all its options but when choosing the options, it only takes the number 1 and the 5 that ask for data, after entering these data, two pass things: It does not do a...
asked by 19.03.2018 / 16:24
1
answer

Display data from a LinkedList Java class

Good, I have a problem when collecting the data of a class, and display them in a linked list. When the method showMiLista (LinkedList list) is executed, it returns an output in the format People @ 28d93b30 Thanks. Biografias.java package...
asked by 25.09.2016 / 15:07
2
answers

When in.close () is used; of the Scanner class?

I am trying to compile the program to know if it is even or odd and I get an error "Resource leak: input never close", where it is recommended to close the Scanner? package pares; import java.util.Scanner; public class Pares { public stati...
asked by 16.05.2017 / 02:42
1
answer

Scanner assigned by reference

I'm trying to collect several numbers to add them. The first number I receive is the number of numbers that will be entered per console, and the rest are the numbers to be added separated by a space, so that the scanner receives something like t...
asked by 21.11.2016 / 19:46
2
answers

Error in reading data type INT with JAVA Scanner [Resolved]

I have a problem reading data int with 'nextInt' and I do not know what it can be. I leave the method that is giving me the error; If something is missing or you want the complete code, you can ask me. Could you tell me what it can be? sta...
asked by 23.05.2018 / 10:06
1
answer

When I enter the amount of albums sold by different artists, how can I detect the person who sold the most?

package cantanteFamoso; import java.util.ArrayList; import java.util.Scanner; public class ListaCantantesFamosos extends cantanteFamoso { public ListaCantantesFamosos(String nombre, String pais) { super(nombre, pais, discosVendi...
asked by 30.04.2018 / 17:17
0
answers

Scan documents with Java

I am trying to use a scanner with CmdTwain and Java to scan documents. The problem is that it does not always work. The other problem is that even with the installed drivers does not work on all computers, even if they all have the same OS, Wind...
asked by 26.06.2018 / 17:17
0
answers

WIA 2.0 Scan documents both sides in Java

I am developing a desktop application in java to scan documents and save them in a database or directory, I use the WIA library (Windows Image Acquisition) and COM4J to use the objects of that library, I have managed everything except the scanni...
asked by 22.03.2017 / 20:14