I read a book on Java and got confused in terms.

For example, it is difficult to understand terms like ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ , класс , ΠΌΠ΅Ρ‚ΠΎΠ΄ , конструктор , Π°Ρ€Ρ‚Ρ€ΠΈΠ±ΡƒΡ‚ .

Who can very well explain them?

Closed due to the fact that the issue is too general for the participants Shwarz Andrei , Grundy , cheops , Yura Ivanov , Alexey Shimansky 3 Sep '16 at 9:52 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See β€œHow to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

    2 answers 2

    • Class this kind of entity, which is the base in OOP language. It can represent an object from the real world or subject area. Typically, a class defines some behavior, it is expressed in the form of methods. Also, a class may have some properties - these are attributes or fields of the class.
    • An object is an instance of some class. Let me give you an analogy from the real world, there is an apple fruit - this is a class, and a specific object of this class is a fruit that hangs on a tree or lies on a store counter.
    • A constructor is a special method that allows you to create objects of this class.
    • An attribute is an internal state or property of an object. For example, if you go back to apples, an attribute for them can be color, size, variety, etc.
    • Methods are certain actions that can be performed on an object. For example, a person can have run , sleep , eat , etc. methods defined.
       public class DataStructure { // Бвойства класса private int size = 15; private int[] arrayOfInts = new int[size]; //ΠšΠΎΠ½ΡΡ‚Ρ€ΡƒΠΊΡ‚ΠΎΡ€ ΠΏΠΎ-ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ, Ρ‚Π°ΠΊ ΠΊΠ°ΠΊ Π½Π΅ ΠΏΡ€ΠΈΠ½ΠΈΠΌΠ°Π΅Ρ‚ Π½ΠΈΠΊΠ°ΠΊΠΈΡ… ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ² //Π½ΡƒΠΆΠ΅Π½ для Ρ‚ΠΎΠ³ΠΎ Ρ‡Ρ‚ΠΎ Π±Ρ‹ Π² ΠΌΠΎΠΌΠ΅Π½Ρ‚ ΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΠΈ этого ΠΎΠ±ΡŒΠ΅ΠΊΡ‚Π° //ΠΌΠΎΠΆΠ½ΠΎ Π±Ρ‹Π»ΠΎ Ρ‚Π°ΠΊ ΠΆΠ΅ ΠΏΡ€ΠΎΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Π΅Π³ΠΎ поля(свойства) //Ссли Π² этом ΠΊΠΎΠ½Π΅Ρ‡Π½ΠΎ Π΅ΡΡ‚ΡŒ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎΡΡ‚ΡŒ. public DataStructure() { //do nothing } //ΠšΠΎΠ½ΡΡ‚Ρ€ΡƒΠΊΡ‚ΠΎΡ€ ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ ΠΏΡ€ΠΈΠ½ΠΈΠΌΠ°Π΅Ρ‚ Π½Π° Π²Ρ…ΠΎΠ΄ //ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΡƒΡŽ Ρ‚ΠΈΠΏΠ° int ΠΈ этой ΠΆΠ΅ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎΠΉ //ΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΡƒΠ΅Ρ‚ сойство класа this.size public DataStructure(int i) { this.size = i; } //ΠœΠ΅Ρ‚ΠΎΠ΄ класса ΠΌΠΎΠΆΠ΅Ρ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒΡΡ для: //изминСния свойств самого ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π°, получСния ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΠΈ ΠΎΠ± ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π΅, //выполнСния ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ Π½Π°Π΄ Π΄Π°Π½Π½Ρ‹ΠΌΠΈ ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ Π² Π½Π΅Π³ΠΎ ΠΏΠ΅Ρ€Π΅Π΄Π°ΡŽΡ‚ ΠΈΠ»ΠΈ Π½Π°Π΄ //Π΄Π°Π½Π½Ρ‹ΠΌΠΈ самого этого ΠΎΠ±ΡŒΠ΅ΠΊΡ‚Π°. public void printEven() { System.out.println("Size:" + size); } //ΠΌΠ΅Ρ‚ΠΎΠ΄ просто Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡŽ ΠΎΠ± ΠΎΠ΄Π½ΠΎΠΌ ΠΈΠ· своих свойств public int getSize(){ return size; } //ΠΌΠ΅Ρ‚ΠΎΠ΄ измСняСт свойство ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° public void setSize(int i){ this.size = i; } } public class Main{ public static void main(String[] args){ //Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ экзСмпляры класса DataStructure dataStructure = new DataStructure(); DataStructure dataStructure2 = new DataStructure(23423); /*Π’ этом ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π΅ dataStructure - это ΠΎΠ±ΡŠΠ΅ΠΊΡ‚(экзСмпляпр) класса DataStructure */ //достаСм Π΄Π°Π½Π½Ρ‹Π΅ ΠΈΠ· ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° int size = dataStructure.getSize();//15 int size2 = dataStructure2.getSize();//23423 //измСняСм свойство ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π° dataStructure.setSize(42); //Π²Ρ‹Π·Ρ‹Π²Π°Π΅ΠΌ ΠΌΠ΅Ρ‚ΠΎΠ΄ ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π½Π΅ измСняСт свойств //Π° просто Π²Ρ‹Π²ΠΎΠ΄ΠΈΡ‚ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡŽ Π² консоль dataStructure.printEven();//42 } }