Hello.

  1. Do not tell me where you can download or view the original java library documentation in order to be able to learn it (classes, methods and how to use them correctly).

  2. Add import.io.*; , to use the cons.readLine(); method cons.readLine(); . The compiler does not skip cons.readLine , cons.printf("Π’Π²Π΅Π΄ΠΈΡ‚Π΅ имя") , or int c = System.in.read(); , gives an error, underlines the red line cons and System.in.read() .

Do not know where the error in my actions? Eclipse development environment.

 package имя; import java.io.*; public class класс { public static void main(String[] args) { System.out.println("Hallo World"); cons.printf("Π’Π²Π΅Π΄ΠΈΡ‚Π΅ имя"); String name = cons.readLine(); } } 
  • Just a comment to the author of the question: Java is a strict language. Most of them are strict with the use of RAM, therefore it is necessary to always declare and type variables. - Anatoly Sokolov

3 answers 3

@ Aleksandr1111: System.console (). ReadLine ()? Well, or smoke this answer, if your IDE System.console () gives null.

  • As I understand it, there is a typo in the tutorial, the code omits the operation to create an object of the Console class with the name cons. Thanks for the answer! - Aleksandr1111

@ Aleksandr1111 , indeed, read the documentation
(and first some textbook).

In http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html (the first link in Google for "java read") writes that .read()

 Throws: IOException - if an I/O error occurs. 

This means either it should be enclosed in a try { ... } catch (IOException e) { ... } , or simply add the word throws Exception after main (...)

(I think, in any book on Java, all this is explained in detail).

    1. Try to drive in Google magic spell "java documentation". I understand that it is difficult, but I assure you, you will find a lot of new and interesting

    2. What is cons and where did you get it from? I suspect that this is the question your compiler is asking.

    Update

    I took the cons from the tutorial for jave as an example of keyboard input

    I will explain my thought in a little more detail. You have never declared this your cons. It is quite logical that your compiler does not know what it is (by the way, I, too). You will not tell the compiler "Well, damn, man, I took this cons from the Java tutorial, but you can trust it"

    • I took the cons from the tutorial on jave as an example of data input from the keyboard, how to use the readLine method correctly? Magic spell works a lot of new, not looking there. - Aleksandr1111
    • one
      > cons I took from the tutorial on jave as an example of data entry from the keyboard, I will explain my point in a little more detail. You have never declared this your cons. It is quite logical that your compiler does not know what it is (by the way, I, too). You will not tell the compiler "Well, damn it, man, I took this cons from the Java tutorial, but you can believe it" - DreamChild