How to set up smartphones and PCs. Informational portal
  • home
  • Mistakes
  • Java programming language tutorial. How to Learn Java Programming - The Complete Guide

Java programming language tutorial. How to Learn Java Programming - The Complete Guide

I have been programming in Java for 7 years now. But at work, you often have to train a new generation. In this regard, I decided to make some cheat sheet, which, I hope, will be useful for Habrchan. If someone can help supplement the information from this article with something, then write! So:

Essential Resources for Initial Learning

  • www.javable.com - a site with articles and a tutorial on Java. Everything is mostly in Russian.
  • www.exampledepot.com - very useful resource where collected brief examples using classes for certain packages
  • java.sun.com - you can't do without the original source. For any Java programmer, JavaDoc should be the ultimate truth. Also here you can find a series of tutorials on all possible topics.

Basic Java packages

Below is a list of Java packages that a programmer should be fluent in. It is recommended to get acquainted with them both by JavaDocs and with the help of www.exampledepot.com. All packages are arranged in the recommended order for study. So:
  1. java.lang is the foundation of the basics. Each class in this package needs individual attention.
  2. java.io - no program can do without I/O operations.
  3. java.util - The package basically contains everything you need to work with collections: Collection, Enumeration, Set, List, Map, etc. etc.
  4. java.net - contains the main classes for working with the network.
  5. java.text - everything you need to format text
  6. java.lang.reflect - Java wouldn't be Java if it wasn't for Reflection. Reflection blurs the line between data and code.
  7. javax.sql - everything you need to work with databases
  8. javax.xml.* , org.w3c.dom.* , org.xml.sax.* - working with XML is simply unthinkable without these packages

Resources to broaden your horizons

  • onjava.com - sooner or later, all the news from the Java world ends up here
  • www.javaspecialists.eu - a resource useful for both beginners and advanced programmers, as it contains many articles about the intricacies of working with Java.
  • www.theserverside.com - It is recommended to subscribe to the RSS, as very interesting things about Java often slip through.

Java Libraries Everyone Should Know

Java doesn't end with just knowing the features of the JSDK. To feel comfortable, you need to know about a dozen or two third-party libraries used by Java programmers everywhere. So let's start with the basics:
  • Commons Lang - what is "forgotten" to include in the JDK
  • Commons Math is a great addition to java.math
  • Commons Logging - logging must be competent. For System.out.println to display logs, novice programmers should chop off their hands after a week of training.
  • 2 months Java learning EE (2 times a week for 4 hours)
  • if you show good results (you defend your project successfully, which you write these two months), then you are offered a job.
The company is very good, foreign, well-known, and the working conditions are excellent - in a word, I wanted to go there much more than to where they had already made me an offer. The selection process involved 3 stages:
  1. Performing practical tasks at home.
  2. If successful, you will be invited to computer testing in the office.
  3. In case of successful testing, you will be interviewed on the same day.
With practical tasks I managed without special problems- here many thanks to JavaRush and their tasks, after which these tasks seemed quite simple. There were 3 tasks: on RegExp (Google helped, because I myself couldn’t stand them and didn’t remember them), on algorithms (quite simple, more like a thinker) and on writing / reading from a file (there are a lot of such in the JavaRush course). I was invited to computer testing. I prepared for testing on the quizful site. These tests helped a lot, some questions even intersected in the end. I passed the test successfully, they began to interview me. I will probably never forget this interview in my life. All that the person interviewing me wanted to hear from me was the basics of Java theory, such as:
  • how checked exceptions differ from unchecked;
  • what methods does the Object class have and why are they needed;
  • what collections are and why they are;
  • and a little about multithreading.
JavaRush is a great course, it will teach you how to solve problems and program, but the theory (for interviews) needs to be learned separately, which I was convinced of by swimming in these issues like a fish in an aquarium. They wanted to wrap me up. I understand him - I could not clearly answer almost anything, I tried to tell everything from the point of view of writing code, and he was interested in theory. But I knew for sure that I really wanted to get into this internship, and I knew that if I was given time, I would make up for it all and learn the unfortunate theory. I told him all this, and he went to meet me halfway - he offered to meet again in a week, but for now he gave a list of topics (approximately as I described above) and said where they can be learned - just an oracle tutorial, it contains all: http://docs.oracle.com/javase/tutorial/ In a week I thoroughly studied this tutorial and went to a second interview on the eve of the day when I was expected to new job. Apparently, the person who interviewed me was most of all hooked by my determination (I knew that if I entered this internship, the future depended only on me - in two months I would have figured out everything I needed). Be that as it may, I entered this internship and refused to go to work at the place where I was offered earlier. For 2 months we were introduced to many topics from Java EE, such as: Servlets, JSP, Hibernate JSF, Spring and much more - after the internship, we were familiar (we had a rough idea) about the main stack Java technologies EE. Also, during the internship, we wrote our own project, which at the end had to be successfully submitted for employment. I just remember my first feelings when I was at the first lecture. I looked at the task of this project (it was issued immediately at the very first lecture) and did not even understand where to start here and how to do it. I also remember what it took me to successfully do it. These two months, almost all the thoughts in my head were that successful employment and the fulfillment of a dream are in my hands and nothing more. No one else depended on whether I could do it. Only from me. I had already quit my job, I was sitting with almost no money, and it was really hard. I sat in the morning, sat in the afternoon, sat in the evening, but did not get tired of rejoicing - I don’t remember when else I devoted myself to something with such obsession. This time once again helped me realize how much I like programming and how much I would like to work in this area. At graduation, I presented my project. I defended it really well, apparently much better than expected, and as an exception I was hired not for the initial position, but immediately for the position of Middle Java Developer. It was December 9, 2014. I couldn't believe it, but the job offer was in front of me on my monitor. Software engineer. This happened. On December 15, I went to work. I have never had the thought "damn, I don't want to go to work." Every day, leaving the house in the morning, I know why I am going to work, what I will do, and how much I want it. This is extremely pleasing. It is worth it and worth the price you had to pay to achieve your dream. I wish all of you who really want to be a programmer to go forward in achieving your goal. It is more than real, it is very close, but you have to pay for it. Pay with your wasted time, nerves, because learning something from scratch is really not the best easy step. JavaGush helped me take these first steps with ease, and I didn't turn my back on programming at the very beginning because of the apparent complexity and abundance of theory. This way I was able to bring my rather crazy idea of ​​​​a radical change of area professional activity(even in the absence of technical education) to the end. And you definitely can. In this article I will try to explain the basics of programming in Delphi as simply and clearly as possible.

Java for dummies. Lesson 1. Program 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 web page of the site. For example, it can 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. And servlets are also possible - 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 the greeting hello world. If you don't have Java, then it can be downloaded from the official site http://www.java.com/en. Then install it.

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

Public class HelloWorld {

public static void main ( String args ) {

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

}

}

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

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

pause

If there are no errors during compilation:

then, most likely, the compilation was successful and you have it in the same directory where HellowWorld was. java HellowWorld 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, then you should get the following result:

If you got it, then I can congratulate you - you have written your first Java program. 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 can see, it starts with the word public. This is a modifier that means that we are declaring something public: 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 will get to the modifier. Now consider the following class keyword. It means that we are declaring a class. Everything in java is based on classes. One of the classes must be the base class. And the base class must be public. In this example, this is the HelloWord class. For now, he's the only one we have.

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

Recall the school course of zoology. How is the living world classified? First, the concept of "kingdom" is introduced.

1. The kingdom of unicellular,

2. plant kingdom

3. Animal Kingdom.

Let's take animals. They can be divided into types. For example:

1. Type intestinal.

2. Type flatworms.

3. Shellfish type.

4. Type chordates.

The latter are divided into mammals, reptiles, amphibians, birds, etc. You can go even further into the classification, but now we will not do this, but will go directly to programming.

In the Java language, you can, like 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 kind of demiurge (creator, god), create life on Earth. First you developed the simplest organic compounds. So, for the sake of experiment, what happens. Then they combined them into complex molecules, from which, like bricks, they assembled the simplest microorganisms. But your ultimate goal is to create intelligent life. Therefore, you did not stop there, but created multicellular organisms. Then they began to improve and develop them. Some species were viable, some became extinct (dinosaurs). And finally, the goal was achieved - Homo Sapiens appeared - a reasonable person.

And now let's descend from heaven 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 imagine that an atom is the simplest command programs or a unit of information (which, you see, are inseparable from each other, because the program works with what - correctly, with information).

Then the molecule is a subroutine. Or an object.

Here we have created a bunch of objects in our program. It is necessary to classify them somehow, so as not to get confused. That's what Java provides for classes ( class ). With the help of them, we describe the class of objects ( 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 very word Birds, and the object is some kind of specific bird, if we continue our analogy.

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

Different birds have different colors of feathers, the shape of the beak and wings. So for classes, when creating a new class, inherited characteristics can be changed. It is called polymorphism.

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

This is how we declare the 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 starting the program. That is why its name must match the file name, so that the interpreter "knows" where to start the program execution.

The base class (HelloWorld ) has base method:main. We have declared it as public and static. The first one indicates that this method is public. If this were not so, then the program would simply not start. There are also methods that are not public, but we will talk about them in the next lessons, for now just remember that the base method (which we run when the program starts) 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) has not been created. In general, fields and methods with the static modifier are common to all objects of the class. We will 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 type is also set in the method declaration. If not, then put void (as in our example).

Access to the fields and methods of the object goes 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 refer to the out field, which is also an object intended for data output, and call its print method, which displays text on the screen (as in the good old BASIC, the PRINT command).

(C) Shuravin Alexander

Java is considered one of the most significant and widely used programming languages ​​because of its unique role in the development of applications for the Internet.
The purpose of this book is to teach you, the reader, the fundamentals of programming in Java language. It takes a step-by-step approach to language learning through numerous examples, self-test exercises, and simple projects. For learning Java This book does not require any prior programming experience. The book starts with the most basic concepts, including compiling and running Java programs. Then we will talk about keywords and linguistic means and constructions that make up Java foundation. After that, more advanced Java language features are covered, including multi-threaded programming and generics. And the book ends with an introduction to the Swing library. All this will give you a clear understanding of the basics of Java programming.

Origins of Java.
The main reasons for creating a new programming language are the improvement of the art of programming or changes in the computing environment. And Java is no exception to this rule. Drawing on the rich legacy of C and C++, this programming language has been refined and enhanced with tools that reflect the current state of the art in programming. Responding to the needs of the emerging interactive environment, Java provides tools that make it easy to create application programs with a highly distributed architecture.

Java was conceived in 1991 by Sun Microsystems employees James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan. At first, this language was named Oak, but in 1995 it was renamed Java. Oddly enough, the developers of the language did not originally intend it for the development of Internet applications. They sought to create a platform-independent language in which to create an embeddable software for various household appliances with microprocessor control, including toasters, microwave ovens and consoles remote control. Such devices used controllers based on microprocessors of different architectures, and the executable code generated by the compilers of most of the programming languages ​​that existed at that time was focused on a specific processor. A typical example of this is the C++ language.

Table of contents
Introduction
Chapter 1 Java Basics
Chapter 2 Introduction to Data Types and Operators
Chapter 3 Control Statements
Chapter 4 Introduction to Classes, Objects, and Methods
Chapter 5 additional information about data types and operators
Chapter 6. More about methods and classes
Chapter 7
Chapter 8 Packages and Interfaces
Chapter 9 Exception Handling
Chapter 10 Data I/O
Chapter 11 Multithreaded Programming
Chapter 12 Enums, Autoboxing, Static Imports, and Annotations
Chapter 13 Generalizations
Chapter 14: Applets, Events, and More
Chapter 15 Introduction to Swing
Appendix A. Answers to self-test questions
Appendix B. Using Documentation Comments in Java Index.

Free download e-book in convenient format, watch and read:
Download book Java, A Beginner's Guide, Herbert Schildt, 2012 - fileskachat.com, fast and free download.

I have been programming in Java for 7 years now. But at work, you often have to train a new generation. In this regard, I decided to make some cheat sheet, which, I hope, will be useful for Habrchan. If someone can help supplement the information from this article with something, then write! So:

Essential Resources for Initial Learning

  • www.javable.com - a site with articles and a tutorial on Java. Everything is mostly in Russian.
  • www.exampledepot.com - a very useful resource, which contains brief examples of using classes for certain packages
  • java.sun.com - you can't do without the original source. For any Java programmer, JavaDoc should be the ultimate truth. Also here you can find a series of tutorials on all possible topics.

Basic Java packages

Below is a list of Java packages that a programmer should be fluent in. It is recommended to get acquainted with them both by JavaDocs and with the help of www.exampledepot.com. All packages are arranged in the recommended order for study. So:
  1. java.lang is the foundation of the basics. Each class in this package needs individual attention.
  2. java.io - no program can do without I/O operations.
  3. java.util - The package basically contains everything you need to work with collections: Collection, Enumeration, Set, List, Map, etc. etc.
  4. java.net - contains the main classes for working with the network.
  5. java.text - everything you need to format text
  6. java.lang.reflect - Java wouldn't be Java if it wasn't for Reflection. Reflection blurs the line between data and code.
  7. javax.sql - everything you need to work with databases
  8. javax.xml.* , org.w3c.dom.* , org.xml.sax.* - working with XML is simply unthinkable without these packages

Resources to broaden your horizons

  • onjava.com - sooner or later, all the news from the Java world ends up here
  • www.javaspecialists.eu - a resource useful for both beginners and advanced programmers, as it contains many articles about the intricacies of working with Java.
  • www.theserverside.com - It is recommended to subscribe to the RSS, as very interesting things about Java often slip through.

Java Libraries Everyone Should Know

Java doesn't end with just knowing the features of the JSDK. To feel comfortable, you need to know about a dozen or two third-party libraries used by Java programmers everywhere. So let's start with the basics:
  • Commons Lang - what is "forgotten" to include in the JDK
  • Commons Math is a great addition to java.math
  • Commons Logging - logging must be competent. For System.out.println to display logs, novice programmers should chop off their hands after a week of training.

Top Related Articles