Java Basics. What does the “JAVA from scratch” course consist of?

💖 Do you like it? Share the link with your friends

Java is the name given not only to the language itself, but also to the platform for creating enterprise-level applications based on this language.

Initially, the programming language was called Oak (Russian). Oak) and was developed by James Gosling for consumer electronics, but was later renamed Java and began to be used for writing client applications and server software. Named after the brand of Java coffee, beloved by programmers, which is why the official logo Java language a cup of steaming coffee is depicted.

Main features of the language

The latest release is version 1.6, which has improved the security system, improved support for the Mozilla Rhino scripting language, improved desktop integration, and added some new features in creating graphical interfaces.

Java and Microsoft

The following companies mainly focus on Java (J2EE) technologies rather than .NET, although they also deal with the latter: IBM, Oracle. In particular, the Oracle DBMS includes the JVM as its component, which provides the ability to directly program the DBMS in the Java language, including, for example, stored procedures.

Key Features

Example program

Program that prints "Hello, World!":

Public class HelloWorld ( public static void main(String args) ( System .out .println ("Hello, World!" ) ; ) )

Example of using templates:

Import java.util.*; public class Sample ( public static void main(String args) ( // Create an object using a template. List strings = new LinkedList () ; strings.add("Hello"); strings.add("world"); strings.add("!"); for (String s: strings) ( System .out .print (s) ; System .out .print (" " ) ; ) ) )

Key Ideas

Primitive types

There are only 8 scalar types in Java: boolean, byte, char, short, int, long, float, double.

Wrapper classes of primitive types

Lengths and value ranges of primitive types are defined by the standard, not implementation and are shown in the table. The char type was made two-byte for ease of localization (one of the ideological principles of Java): when the standard was being developed, Unicode-16 already existed, but not Unicode-32. Since there was no single-byte type left as a result, a new type byte was added. The types float and double can have special values, and "not a number" (

Type Length (in bytes) Range or set of values
boolean undefined true, false
byte 1 −128..127
char 2 0..2 16 -1, or 0..65535
short 2 −2 15 ..2 15 -1, or −32768..32767
int 4 −2 31 ..2 31 -1, or −2147483648..2147483647
long 8 −2 63 ..2 63 -1, or approximately −9.2 10 18 ..9.2 10 18
float 4 -(2-2 -23) 2 127 ..(2-2 -23) 2 127, or approximately −3.4 10 38 ..3.4 10 38, as well as , , NaN
double 8 -(2-2 -52)·2 1023 ..(2-2 -52)·2 1023 , or approximately −1.8·10 308 ..1.8·10 308 , as well as , , NaN

Such strict standardization was necessary to make the language platform-independent, which is one of the ideological requirements for Java and one of the reasons for its success. However, one small problem with platform independence still remains. Some processors use 10-byte registers to store results intermediately or otherwise improve the accuracy of calculations. In order to make Java as compatible as possible between different systems, earlier versions any means of increasing the accuracy of calculations were prohibited. However, this led to a decrease in performance. It turned out that few people need a deterioration in accuracy for the sake of platform independence, especially if they have to pay for it by slowing down the programs. After numerous protests, this ban was lifted, but added keyword strictfp, which disables increasing precision.

Transformations for mathematical operations

The following rules apply in Java:

  1. If one operand is of type double, the other is also converted to type double.
  2. Otherwise, if one operand is of type float, the other is also converted to type float.
  3. Otherwise, if one operand is of type long, the other is also converted to type long.
  4. Otherwise, both operands are converted to type int.

The last rule distinguishes Java from older implementations and C++ and makes the code more secure. So, for example, in the Java language, after executing the code

Short x = 50 , y = 1000 ; int z = x*y;

the z variable is assigned the value 50000, rather than −15536, as in most hopelessly outdated C and C++ implementations. In a program compiled by MS VC++, starting with version 7, as well as many other modern compilers (gcc, Intel C++, Borland C++, Comeau, etc.), the value will also be 50000.

Object variables, objects, references and pointers

Java only has dynamically created objects. Moreover, object type variables and objects in Java are completely different entities. Object type variables are references, that is, implicit pointers to dynamically created objects. This is emphasized by the syntax for describing variables. So, in Java you cannot write:

Double a[ 10 ] [ 20 ] ; Foo b(30) ;

Double a = new double [ 10 ] [ 20 ] ; Foo b = new Foo(30 ) ;

When assigning, passing to subroutines, and comparing, object variables behave like pointers, that is, object addresses are assigned, copied, and compared. And when accessing an object's data fields or methods using an object variable, no special dereferencing operations are required—the access is performed as if the object variable were the object itself.

Object variables are any type except simple numeric types. There are no explicit pointers in Java. Unlike pointers in C, C++ and other programming languages, references in Java are highly secure due to strict restrictions on their use, in particular:

  • You cannot convert an object of type int or any other primitive type to a pointer or reference and vice versa.
  • It is prohibited to perform ++, −−, +, − or any other arithmetic operations on references.
  • Type conversion between references is strictly regulated. With the exception of array references, it is only permissible to convert references between an inherited type and its descendant, and the conversion from an inherited type to an inherited type must be explicitly specified and checked at runtime to make sense. Conversions of array references are allowed only if conversions of their underlying types are allowed and there are no dimension conflicts.
  • In Java, there is no operator for taking an address (&) or taking an object at an address (*). An asterisk in Java means multiplication, and nothing more. The ampersand (&) just means “bitwise and” (the double ampersand means “logical and”).

Thanks to such specially introduced restrictions in Java, direct manipulation of memory at the level of physical addresses is impossible (although there are links that do not point to anything: the value of such a link is denoted by null).

Duplicate links and cloning

Because object variables are reference variables, assignment does not copy the object. So, if you write

Foo foo, bar; ... bar = foo;

then the address from the foo variable will be copied to the bar variable. That is, foo and bar will point to the same memory area, that is, to the same object; attempting to change the fields of an object referenced by foo will change the object referenced by bar , and vice versa. If you need to get just one more copy source object, use either the method (member function, in C++ terminology) clone(), which creates a copy of the object, or a copy constructor.

The clone() method requires that the class implement the Cloneable interface (see interfaces below). If a class implements the Cloneable interface, by default clone() copies all fields ( small copy). If you want to clone fields rather than copy them (as well as their fields, etc.), you need to override the clone() method. Defining and using the clone() method is often a non-trivial task.

Garbage collection

In the Java language, it is not possible to explicitly remove an object from memory - instead, garbage collection is implemented. A traditional trick that gives the garbage collector a “hint” to free memory is to assign a variable the empty value null . This does not mean, however, that an object replaced by null will necessarily be immediately deleted. This technique simply removes the reference to the object, that is, it unbinds the pointer from the object in memory. It should be taken into account that an object will not be deleted by the garbage collector as long as it is pointed to by at least one reference from the variables or objects used. There are also methods to force garbage collection, but these are not guaranteed to be called by the runtime and are not recommended for normal use.

Classes and Functions

Java is not a procedural language: any function can only exist within a class. This is emphasized by the terminology of the Java language, where there is no concept of “function” or “member function”. member function), but only method. Standard functions have also turned into methods. For example, in Java there is no sin() function, but there is a method Math.sin() of the Math class (which, in addition to sin(), contains the methods cos(), exp(), sqrt(), abs() and many others).

Static methods and fields

In order to avoid the need to create an object of the Math class (and other similar classes) every time you need to call sin() (and other similar functions), the concept static methods(English) static method; sometimes in Russian they are called static). A static method (marked with the static keyword in its description) can be called without creating an object of its class. Therefore you can write

Double x = Math.sin(1);

Math m = new Math(); double x = m.sin(1);

The limitation on static methods is that they can only access static fields and methods in the this object.

Static fields have the same meaning as in C++: each exists only in a single copy.

Finality

The final keyword means different things when declaring a variable, method, or class. The final variable (named constant) is initialized upon description and cannot be changed further. The final method cannot be overridden by inheritance. The final class cannot have heirs at all.

Abstractness

In Java, methods not explicitly declared final or private are virtual in C++ terminology: calling a method defined differently in a base class and a subclass always involves a runtime check.

An abstract method (abstract descriptor) in Java is a method for which the parameters and return type are specified, but not the body. An abstract method is defined in descendant classes. In C++ the same thing is called a pure virtual function. In order for abstract methods to be described in a class, the class itself must also be described as abstract. Objects of an abstract class cannot be created.

In this article I will try to present the basics of programming in Delphi as simply and clearly as possible.

Java for dummies. Lesson 1. Hello World!

First, I'll tell you what Java can do. Firstly, in this language you can write applets - programs that are embedded in the website’s web page. For example, it could be a game, a business graphics system, and much more. Secondly, you can write full-fledged applications in Java that are not necessarily related to the Web. Or you can use servlets - programs that, unlike applets, are executed not on the client side, but on the server side.

Let's start with the very basics. Let's pay tribute to tradition and write the simplest program, which displays a greeting Hello World. If you don't have Java, then it can be downloaded from the official website http://www.java.com/ru. Then install it.

If Java you have installed, then type the following text in some editor:

{

Public static void main ( String args ) {

System . out . print ( "Hello, world!" );

}

}

And be sure to save it under the name HelloWorld. java- The name of the executable class must match the file name. To compile, use the program javac.exe included in the standard package Java. This is what a compilation batch file might look like this java file:

"c:\Program Files\Java\jdk1.7.0\bin\javac" HellowWorld.java

pause

If no errors occurred during compilation:


then, most likely, the compilation was successful in yours in the same directory where HellowWorld was located. java HellowWorld has also appeared.class:

Now let's run another batch file that will call the Java interpreter along with our compiled file:

"c:\Program Files\Java\jdk1.7.0\bin\java" HellowWorld

pause

If everything is done correctly, you should get this result:


If you received it, then I can congratulate you - you have written your first program in Java. In the future we will learn how to write Java applets, and much more. And now a few words about the program itself. As you noticed, it starts with the word public. This is a modifier that means that we are declaring something publicly available: a class, a class method, or a variable. There are other modifiers, for example: private, protected, friendly, final, abstract, static. Some of them can be combined with each other. For example, private means that the variable we want to declare is private to other classes. But we'll get to the modifier later. Now let's look at the next keyword, class. It means that we are declaring a class. In java everything is based on classes. One of the classes is necessarily the base one. And the base class must be public. In this example, it is the HelloWord class. For now he is the only one we have.

Now I'll try to explain in simple words, what is it Class and what is an object.

Let's remember the school zoology course. How is the living world classified? First, the concept of “kingdom” is introduced.

1. Kingdom of unicellular organisms,

2. plant kingdom

3. Animal kingdom.

Let's take animals. They can be divided by type. For example:

1. Type coelenterates.

2. Type of flatworms.

3. Type of shellfish.

4. Phylum chordata.

The latter are divided into mammals, reptiles, amphibians, birds, etc. You can go even further into the classification, but we won’t do that now, but will move directly to programming.

In the Java language, you can, similar to the classification of the living world, classify objects (pieces of program and data). It has classes for this.

Stop stop! - you say, - why classify these objects?

Imagine that you, like some demiurge (creator, god), are creating life on Earth. First you developed the simplest organic compounds. So, for the sake of experiment, what will happen. Then they combined them into complex molecules, from which, like bricks, they assembled the simplest microorganisms. But your ultimate goal is the creation of intelligent life. Therefore, you did not stop there, but created multicellular organisms. Then they began to improve them and develop them. Some species turned out to be viable, some became extinct (dinosaurs). And finally the goal was achieved - Homo Sapiens - Homo sapiens - appeared.

Now let’s come down to earth and imagine programming as a creation, where you force your program to evolve to a certain state when it can be used, and then further, gradually increasing and improving functionality.

Now let's imagine that an atom is simplest command programs or a unit of information (which, you see, are not separable from each other, because the program works with something - that’s right, with information).

Then the molecule is a subroutine. Or an object.

So we created a bunch of objects in our program. We need to classify them somehow so as not to get confused. This is what Java provides classes for. Using them, we describe a class of objects (a general concept, for example birds), and then, having the described class, we can create an object - an instance of this class. That is, the class is the word Birds itself, and the object is some specific bird, if we continue our analogy.

Further, birds are different types. But they all have some common characteristics, inherited from the concept of “Birds”. Likewise in Java, from a class you can create another class that inherits its properties and methods (features). It is called inheritance.

Different birds have different feather colors, beak and wing shapes. Likewise for classes, when creating a new class, inherited characteristics can be changed. It is called polymorphism.

So, we figured out the basic concepts of Java. Now let's go through the program.

This is how we declare a class:

public class HelloWorld {

In this case, there is only one class in our program, and this is the base class, that is, the class responsible for launching the program. That is why its name must match the name of the file, so that the interpreter “knows” where to start executing the program.

The base class (HelloWorld) has a base method: main. We declared it as public and static. The first indicates that the method is public. If this were not so, then our program simply would not start. There are also methods that are not publicly available, but we will talk about them in the next lessons. For now, just remember that the base method (which is launched when we start the program) must be public. And its name should be main so that the interpreter knows where to start executing the program.

Now what is static. This is a modifier that indicates that the method is static. That is, it works even when an instance of the class (object) is not created. In general, fields and methods with the static modifier are common to all objects of the class. We'll also talk about this later.

Each method may or may not have a return value. If it does, then it's a function. The return value type is also included in the method declaration. If not, then set it to void (as in our example).

Access to the fields and methods of an object occurs through a dot. There are also built-in objects, for example, System, which we use in our example:

System . out . print ( "Hello, world!" );

in this case, we access the out field, which is also an object intended for outputting data, and call its print method, which displays text on the screen (like the PRINT command in good old BASIC).

(C) Shuravin Alexander

Java (i.e. Java) is an island in Indonesia, a type of coffee, and a programming language. Three completely different meanings, and they are all important in their own way. However, for most programmers, it is the Java programming language that is of interest. Over the past few years (since late 1995), Java has been able to conquer the developer community. Its phenomenal success has made Java the fastest growing programming language in history. There has been quite a bit of hype around the language and its capabilities. And many programmers, as well as end users, do not fully understand what the Java language is and what capabilities it provides.

Java is a revolutionary programming language

The qualities that make Java so attractive are also found in other programming languages. Many languages ​​are ideal for certain types of applications. Even more than Java. But Java brought all these qualities together in one language. This is a revolutionary leap forward for the software development industry.

Let's take a closer look at some of the properties of this language:

  • object-oriented
  • portability
  • multithreading support
  • automatic garbage collection
  • reliability
  • support for working with the network and the Internet
  • simplicity and ease of use

Object Orientation

Many languages ​​that arose before Java, such as C and Pascal, were procedural languages. Procedures (or functions) are blocks of code that were part of a module or application. Parameters (primitive data types: integers, characters, strings and floating point numbers) were passed to the procedures. The code was processed separately from the data. You had to pass data structures, and procedures could easily change their contents. This caused many problems, since the use of some parts of the program in other parts of the program could produce unpredictable results. It took a huge amount of time and effort to find the faulty procedure. Especially when it came to large programs.

Some of the procedural languages ​​even made it possible to obtain the address of data in memory. Knowing this address, it was possible to read or add data after some time, or accidentally write new information over the old one.

Java is object-oriented language. An object-oriented language works with objects. Objects contain data (fields) and code (methods). Each object belongs to a specific class, which is a "blueprint" that describes the fields and methods that an object offers. In Java, almost every variable is an object of some kind - even a string. Object-oriented programming requires a different type of thinking, but it is a better way of developing software than procedural programming.

Today there are many popular object-oriented languages. Some of them were originally designed to be object-oriented, such as Java and Smalltalk. Others, such as C++, are part object-oriented and part procedural. In C++, you can still overwrite the contents of data structures and objects, causing the application to crash. Fortunately, Java prevents direct access to memory contents, thereby creating a more reliable system.

Portability

Most programming languages ​​are designed for a specific operating system and processor. When compiling source(instructions from which the program is built) turns into machine code, which can only be executed on devices of a certain type. This process produces "internal code" that runs incredibly fast.

There are other types of languages ​​- interpretable. The interpreted code is read software application(interpreter), which performs the specified actions. Interpreted code most often does not need to be compiled - it is translated as it is executed. Because of this, interpreted code runs quite slowly, but it allows programs to be ported between different operating systems and processors with different architectures.

Java takes the best from both technologies. Java code is compiled into platform-independent machine code called Java bytecode. Special interpreter Virtual machine Java or "Java Virtual Machine (JVM)" reads and processes bytecode. In Fig. Figure 1 shows a diagram of a small Java application. The bytecode marked with an arrow is presented in text form, but when compiled, it is represented as bytes to save space.



Rice. 1 - Parsing the bytecode for “HelloWorld”

The approach that Java takes provides several significant advantages over interpreted languages. Firstly, the source code is protected from viewing and modification - only the bytecode is available to users. Secondly, security mechanisms can scan the bytecode for signs of change or presence malicious code, complementing other Java security mechanisms. However, the most important thing is that Java code can be compiled just once, and then run on any device or operating system that supports the Java Virtual Machine (JVM). Java code can run on Unix, Windows, Macintosh, and even Palm Pilot systems. Java can even be run in a web browser or on a web server. Portability allows you to write an application just once and then run it on many various devices. This saves a lot of time and money.

Multithreading

If you've ever written complex applications in C or PERL, then chances are you've come across the concept of multiple processes. An application can split itself into separate copies that run in parallel. Each copy duplicates code and data, resulting in increased memory consumption. Getting these copies to interact is quite difficult. The creation of each process requires access to the operating system, which once again wastes CPU time.

Much the best method is the use of multiple executable threads, simply called streams. Threads can share data and code, making it easier to transfer data between thread instances. They also use less memory and CPU resources. Some languages, such as C++, support threads, but they are very difficult to implement. Java has built-in support for multithreading. Threads require a slightly different way of thinking, but are very easy to understand. Java's support for threads is very easy to use, and they are used quite often in applications and applets.

Automatic garbage collection

No, we're not talking about taking the trash out of the house (although it would be nice to have a computer that could handle this kind of task). The term "garbage collection" refers to the disposal of unused memory areas. When applications create objects, the JVM allocates memory areas to store them. If the object is no longer needed (there are no references to it), this memory area can later be used again.

Languages ​​such as C++ require programmers to manually allocate and free memory for data and objects. This complicates the program and leads to another problem: memory leaks. When programmers forget to clear memory, the amount of free memory available for use decreases. Programs that frequently create and destroy objects can eventually fill up all available memory. IN Java programmer there is no need to worry about such things because the JVM performs automatic garbage collection for objects.

Reliability

Security plays a very important role in Java. Because the Java applets downloaded remotely and executed in the browser, a lot of attention is paid to security. We wouldn't want applets to gain access to our personal documents, delete our files, or cause any harm. There are strict security restrictions at the API level when it comes to applets accessing files and the network. In addition, there is support for checking the integrity of the downloaded code digital signatures. At the bytecode level, obvious hacks such as stack manipulation or invalid bytecode are checked. Java's powerful security mechanisms help protect against unintentional or intentional security breaches, but it's important to remember that no system is perfect. The weakest link in this chain is the Java Virtual Machine, in which everything runs - the JVM can be susceptible to attacks because it has known weak sides. It is worth noting that although several vulnerabilities have been found in the JVM, this happens very rarely and is usually fixed quickly.

Support for working with the network and the Internet

Java was created with the Internet in mind and to support network programming. The Java API provides extensive support network functions, from sockets and IP addresses to URLs and HTTP. There is nothing easier than writing a network application in Java. In this case, the resulting code can be transferred to any platform. In languages ​​such as C/C++, the networking code must be rewritten for each operating system, and usually has a more complex structure. Java's networking support saves a lot of time and effort.

Java also supports more exotic types of network programming, such as remote method invocation (RMI), common object request processor architecture (CORBA), and Jini distributed systems architecture. These distributed systems technologies make Java an attractive language for large-scale projects.

Simplicity and ease of use

The Java language has its roots in the C++ language. C++ is very popular and widespread. And yet it is considered a complex language, with features such as multiple inheritance, templates, and pointers that are counter-productive. In turn, Java is more of a “purely” object-oriented language. There is no access to memory pointers, but rather object references. Support for multiple inheritance has also been removed. This made it possible to achieve more understandable and simple circuits classes. The I/O and networking libraries are very easy to use. The Java API provides developers with a large amount of time-saving code (networking functions and data structures). After working with Java for a while, most developers are reluctant to go back to other languages ​​due to the simplicity and elegance of Java.

Conclusion

Java provides many benefits to developers. Although many of them exist in other languages, Java brings them together. Java's rapid growth has been truly phenomenal, and it still shows no sign of slowing down. In the next article we will talk about the heart of Java - the Java Virtual Machine.


Hello dear reader. I have long wanted to write an article like this, but either I didn’t have enough time or treacherous laziness got in the way. But, be that as it may, I still managed to gather my thoughts to write something that, I hope, will bring you some benefit. I will be happy to share my knowledge and experience, in return you will receive time and attention. In my opinion, this publication is well suited for those who are ready to decide on their interests and want to connect their lives with IT - in one way or another. So, let's go!

Choosing a programming language

The publication is starting to look like many similar materials. According to the law of the genre, I will have to write the name of a couple of three programming languages, name a couple of pros and cons and, in the end, without answering the question, move on to the next part. Partly, there is some truth in this, because everyone chooses the language that is closer to them, based on what type of products they want to develop in the future. Most of you studied Turbo Pascal at school and it will hardly be news to you that almost nothing is written in this language now. So in this case, you need to choose the language wisely, although you can never have too much knowledge, but if you want to effectively join the ranks of programmers in a short period of time, you need to approach the choice of language wisely. At the very beginning, remember: a good programmer will never go hungry, and in most cases will be able to buy himself a lot of caviar(this definition is suitable for any specialty, but no specialty will give you such freedom to choose where to work, both in terms of companies and countries - he is a programmer and a programmer in India).

It is logical that the more popular and in demand a language is, the greater the chances of finding a job in the future, and the language should be easy to learn. Because although a large number of games are written in C++ and they get good money for it, it is better for a beginner, especially one not familiar with OOP (object-oriented programming), to put this language aside for a while. The following link provides a list of the most popular programming languages ​​of 2014, and as you can see, Java is in first place, followed by C languages, then Phyton, JavaScript, PHP, Ruby, etc. If you look for similar statistics yourself, you will see that in different sources places are occupied differently, but in general the first 10 places in content will be the same everywhere.

If you turn to another one, which is based on an analysis of vacancies posted on Twitter, you will see a very similar situation with the first example. And yes, both articles are in English, get used to this, if you want to become a programmer, remember that almost all documentation and sources useful information are written in English, so if your knowledge of this language is weak, add learning and practicing English to your to-do list for tomorrow and the near future. I think I’ll even write a separate article dedicated to learning a foreign language.

Based on these two sources, we can already imagine which programming languages ​​are currently “in fashion”. As the title suggests, the author of the article chose Java for himself. Although I think it is the best for learning OOP, there are many people who will disagree with me, and this is logical - as many people, so many opinions. Here we stand at a small crossroads: choose Java, C# (very similar to Java), Phyton, if we want to work with the fillings of programs and applications (back-end) or PHP, JavaScript, HTML, if we want to do web development (front-end). In the first case, I would choose Java, and in the second, PHP, although again, it’s more to your taste, you have to look for information about various languages ​​yourself and generally understand what you want to do. For thought, here is a selection of languages ​​that are used in the largest Internet companies in the world.

There are 2 main reasons why I would choose either Java or PHP. The first is that these languages ​​are very popular and finding the appropriate job will not be difficult, and the second is that in no other languages ​​will you find as much training material as in these two, both in Russian and in English.


Education

So, we have come to a stage that most people reach without problems, but this period is rightfully one of the most difficult in a programmer’s career. Although a programmer learns throughout his life, the time when he begins to take his first steps largely determines his future fate. In general, training tests a person’s strength, whether he will endure it, whether he will not lose interest in a month (as happens with some), whether he will be able to reach the end and master basic knowledge, on which entire layers of information will then be layered.

In general, I have my own theory, which I have confirmed more than once in practice: Absolutely everything can be learned in 1 year.. Believe me, this is the absolute truth, some may even need less time, but if a person does not stop giving up and approaches learning wisely throughout the year, then it is almost impossible that he will not learn. This is not only in programming, in absolutely any area: if you want to play the guitar - no problem (it didn’t take me that much time and effort), learn Argentine tango, surf - all this is enough for one year. The main thing is to study!

In this case, I will consider the Java language, since it is still closer to me. Fortunately, the Internet is full of people who help others study for free, so finding material that is suitable for you will not be difficult. , which you can view with pen and paper within the walls of your cozy apartment (for now only in Russian). For those who are used to reading the material they are going through, the Internet again provides great opportunities and this is only one of all kinds of sites with Java lessons. There are more than enough theories, but I can’t say anything about a training site like Coursera.org, where you can find training courses in various languages ​​and in various fields, including programming - again, everything is absolutely free. There are not one or two such sites, you just have to search.

But no matter how informative the theory is, programming is indispensable without practice. But even here, half the work has already been done for us and we don’t need to look for various tasks to improve our skills; a service like JavaRush will help a lot with this. In general, this site provides both theory and practice, starting with simply duplicating code from the screen and ending with complex tasks, and during breaks it even offers to relax and watch the well-known animated series. According to the authors, those who have reached level 20 in the service will have sufficient knowledge to already get a job in an IT company. .

Help with practice

As already mentioned, practice is an integral part of any learning, especially in programming. Here you will have to code and code, right down to the muscle memory of your fingers. This, of course, is a little exaggerated, but at first you will really have to hit the keys a lot in order to remember the meanings of various structures so that in the future you can use them almost automatically.

Many novice programmers have a lot of questions at first, especially when they need to complete an independent task. This is fine. But in such situations, you need to understand that almost any question you have can be answered on the Internet. It’s unlikely that you’re the first person to encounter it, so don’t rush to immediately ask questions on various programmer forums (which I’ll write about a little later). Sit for a minute, correctly formulate the problem in your head and feel free to look for it in a search engine. Surely most will search in Russian, but don’t forget that the language of programmers is English, so if you haven’t found the answer in the great and mighty, it’s worth looking in a language that everyone seemed to have studied at school, but never learned. But even if in this case it turns out that there is no answer to your question anywhere, the best Internet forums enter the battle:
documentation of the language in which they write. It describes how certain classes and interfaces work; sometimes documentation is the only source that can help resolve issues, because this is only initial stage everyone has similar questions and you can find them without any problems ready-made solutions, but the further you get into the wilds, the harder and harder it is to find answers, so you have to rely on your, I hope, already smart head.

Compiling the code

I have already written quite a lot, of course, it is difficult to cover such a large topic in one article, but I think the first steps have already been taken and they should evoke the appropriate thoughts in you. I think this is only the first article in the series “How to become a programmer” and, accordingly, “why?” if you are at a crossroads and don’t yet know which path to choose. Next time I will touch on more materially interesting things, because it’s no secret that programmers are not poor people, and we’ll see where and how much they get paid next time.

Finally, for those who really want to become a programmer, I wish you to take the bull by the horns, gather all your will into a fist and do what you like. It has been said thousands of times before, but I will repeat, the main thing is desire and work. Then everything will work out for you. Remember the most important thing: perceive learning programming languages ​​and various technologies not as a goal, but as a MEANS. Just imagine what opportunities are opening up for you. Maybe you will become one of those who changes the world in real time. So good luck and thanks for your attention!

Video bonus

Tags: Add tags

From the author: This programming language powers approximately 3 billion smartphones, 125 million televisions and every single Blu-Ray player in the world. This language regularly takes prizes in software developer ratings and is the most popular among the largest IT companies. It is a technical phenomenon and works on absolutely any device, which corresponds to its “write once, run anywhere” principle (WORA - “write once, run anywhere”). Who guessed it, raise your hands! Of course, this is the Java language. And today I will reveal all my cards to you and tell you the whole truth about how to become a Java programmer from scratch! Make yourself comfortable!

A few facts about Java

In order not to bore you with long theoretical sermons, I have grouped some information about Java into a list, after reading which you will gain an insight into what kind of language it is and what its role in wildlife programming:

Java is a "fashionable" and cross-platform programming language. It works on any device with any operating system. All Google and Android applications are written on it. You will not find so much information and training materials for any other language;

the official release date of the language is May 23, 1995. It was originally intended to be an interactive cable television, but “it didn’t work out.” The inventor of Java is Sun Microsystems, which was acquired by Oracle in 2010;

Many people confuse Java and JavaScript. If you want to do something (websites, web applications), then choose the second option. Java is back-end, i.e. development of application filling;

Modern web development technologies

AngularJS, Webpack, NodeJS, ReactJS, TypeScript, Gulp, Git, Github...
Learn everything about modern technologies in web development

is an object-oriented programming language, the code of which is executed by a special virtual java machine(JVM). In the US, approximately 9 out of 10 computers have this same JVM installed;

The language gets its name from a brand of coffee - which is why the official emblem features an inspiring cup.

Are you still here or have you run to make yourself a cup of aromatic coffee? Then let's continue the conversation about how to become a Java programmer.

Installation of the software environment

Oddly enough, some people have problems already at the stage of installing the Java software environment. To do this, you need to go to the official website of the developer company - Oracle. You will see a link to the current version at the very top of the site. You need Java SE (Standard Edition) and the Java Development Kit - a set of development tools. Please note that there are different distributions for different OS.

Let's say we have Windows. We go to “System Properties” and see what kind of system we have - 32-bit or 64-bit. We download the file that suits us in terms of bit depth. If you choose the wrong distribution, you will receive an error when compiling the code. After confirming the Accept License Agreement, click the download button.

What is the Java Developer Toolkit?

The programmer spends most of his time in the IDE (IntelliJ IDEA, Eclipse, WebStorm, NetBeans). IDE is an integrated development environment, a special interface for programming. Not only does it help you write code, but it also makes it easier to use other programming tools. Some advise those who want to become a Java programmer from scratch to write their first programs in a regular notepad or Notepad++.

Maybe elementary programs should be written in an editor. But in the future I still strongly recommend using the IDE. It has functions for code completion, syntax control, jump to method definition, and many others. And intelligent hints will save you from having to remember all the names of functions and their parameters, which is simply physically impossible.

At teamwork, when several people are working on one program at once, it is necessary to use the so-called version control system (Perforce, Git, Subversion, etc.). However, version control systems are very convenient when working alone.

Approximate algorithm for learning Java

Learning the basics of the Java language. The first step is to develop your logical thinking skills and learn the fundamental concepts of programming language syntax. Armed with a book, article, or instructional video, learn how to create with using the IDE or a text editor are simple Java objects that contain various options behavior depending on the input data.

Analysis of advanced features of the Java language. At this stage, learn the syntax, libraries and frameworks that will be useful to you when creating more complex applications with a practical focus. A good programmer not only knows how to use various libraries, but also knows how they work inside. In addition, concepts such as input/output operations, inheritance and abstractions, serialization, generic types, regular expressions, should not be an empty phrase for you.

Subtleties of programming. Never hesitate to carefully study the documentation and jargon of Java programming. At this stage, you should already be “mutating” into a mature programmer. Chat with Java gurus, which you will find in thematic forums and other environments where programmers gather. Show them your code, consult and advise others - “accumulate karma.” You can even start your own blog, post snippets of your own code on it and see what more experienced programmers have to say about it.

How to start programming?

For those who are planning to become a Java programmer from scratch, I will tell you how to write your first program.
So, open any text editor and write:

Class HelloWorld ( public static void main(String args) ( System.out.println("Hello World!"); ) )

Save the file under the name HelloWorld.java. Please note that Java is case sensitive, so the words "helloworld" and "HelloWorld" are different. If the file and class names in the code are different, the program simply will not start. In addition, it is important that the encoding is ANSI.

Now we have to compile the program using the javac compiler from the JDK. While we have not installed the development environment, we will compile using command line cmd by calling it from the Start menu. In the window that appears, type cmd and press Enter.

If we saved HelloWorld.java to the Prog folder on drive C, then enter the command:

Cd C:\Progа

and press Enter. So we changed the directory to the one where our program is located. Then enter:

Javac HelloWorld.java

Press Enter again. If the system does not generate an error, then the compilation was successful, and in the Prog folder you will find the HelloWorld.class file. I'll explain why it is needed. A file with the .java extension is only a “sketch” of the code, not containing the “technical part”, which affects not the functions, but the launch of the program. And the .class file contains bytecodes that allow you to execute the written code through the Java interpreter.

If you did everything correctly, you will see your creation on the screen, a nascent electronic mind that will greet you: “Hello World!”


Well, that's all for today, dear friends. I hope you understand for yourself how you can become a Java programmer from scratch. In my next article I will talk about how to make money as a Java programmer. So stay tuned, or better yet, subscribe to our blog updates. Bye everyone!



tell friends