Learning the java language from scratch online courses

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

A. N. Vasiliev “Java tutorial with examples and programs” Science and Technology, 2011, 352 pages (46.0 MB djvu + 1.34 MB files)

Self-instruction manual, like any other tutorial, is focused on quick and independent learning on its topic, in this case language Java programming(by this we should understand technology).

There is no need to talk much about how you can become a programmer by reading books: manuals, tutorials, textbooks - all this is not true. Learning a programming language is like learning foreign language, requires not only theoretical knowledge - obtained from books, but also practical exercises. Preferably with native speakers (draw your own conclusions).

As you noticed, the full title of the book is “Java Self-Tutorial with Examples and Programs,” that is, it is implied that the reader will study not only theory, but also perform practical tasks and examples. Which is not a guarantee, but a key guarantee of the likelihood of success for more or less decent programming, in particular in Java.

It is up to you, the reader, to judge whether the author succeeded in his task or not. Just as not everyone can become a mathematician, not everyone can become a programmer (more precisely, a great programmer, although...even bears are taught to jump into hoops).

In one archive there is a book, in the other there are listings with program code For practical work, the Java distribution kit with the Java program development environment (NetBeans) was removed from the archive to reduce its size; you can download their latest versions separately.
ISBN 978-5-94387-937-1


NetBeans Download Page


About the book, language and software 9
JAVA 9 technology
Software 11
About OOP in general and JAVA in particular 20
Useful resources 23
Book 24 structure
Terminology and conventions 25
Feedback 25
Thanks 26

Chapter 1. First program 22
Very simple program 27
Another simple program 36
Summary 39

Chapter 2. Variables and basic data types 41
Variables of basic types 41
How to declare variables 43
Wrapper classes 47
Summary 50

Chapter 3. Basic Operators and Type Casting 51
Arithmetic operators 51
Logical operators 52
Comparison operators 54
Bitwise operators 54
Ternary operator 57
Assignment operator 59
Explicit casting and automatic type expansion 60
Literal types 62
Short forms of operators 63
Increment and decrement 64
Expression Evaluation and Operation Priority 65
Summary 66

Chapter 4. Control instructions 67
Conditional IF Statement 67
Selection statement SWITCH-CASE 76
Loop statements WHILE and DO-WHILE 80
Operator FOR loop 85
Summary 90

Chapter 5. Creating and working with arrays 91
One-dimensional arrays 91
Assigning and comparing arrays 97
Two-dimensional arrays 98
Initializing array 102
Working with arrays 103
FOR loop operator for looping through array elements 108
Summary 109

Chapter 6. Classes and objects classes and objects 111
Declaring a class and creating an object 113
117
Constructors 122
Overloading methods and constructors 125
Assigning objects 130
Creating a copy of an object 132
Summary 136

Chapter 7. Subtleties of working with objects 137
Static fields and methods 137
Objects and Methods 143
Arrays and objects 149
Anonymous objects 153
Internal classes 156
Arguments command line 160
Summary 164

Chapter 8. Inheritance, interfaces and packages 165
Basics of Inheritance 165
Constructor of subclass 169
Method Overriding 172
Closed members of class 177
Superclass Object Variables 180
Abstract classes and interfaces 182
Packages and access levels 193
Summary 195

Chapter 9 Working with text and other utilities 197
Working with text 197
Working with Date and Time 209
Math Utilities 210
Summary 212

Chapter 10. Exception Handling 213
Exceptional situations and their types 213
Exception handling 216
Creating Custom Exception Classes 222
Summary 227

Chapter 11. Multithreaded Programming 228
Implementation of threads in JAVA 228
Main flow 230
Creating a Child Stream 233
Thread synchronization 238
Resume 244

Chapter 12. I/O system 245
Data streams and console input 245
Formatted output 249
Working with files 256
Resume 265

Chapter 13. Graphics in Java. Basics of the SWING library, principles of creating applications with graphical interface 266
Creation simple window 271
Window with text label 273
Window with text and icon 275
Window with label and button 277
Event classes 282
Resume 286

Chapter 14. GUI Applications 287
Creating a window with a text input field 287
Component Class Inheritance 301
Resume 315

Chapter 15. Applets 316
Basic properties of applets and a simple example 316
Passing arguments to the applet 323
Applet with 328 controls
Resume 349
Conclusion 350

Download technical books for free 7.61 mb. epub

In previous lessons, we used methods to output information to the console print() And println(), which output strings or numbers without any formatting. We could implement basic formatting by adding additional spaces or other characters to the lines. In this lesson we will get acquainted with methods that will open up new opportunities for us to formatting strings in Java.

Array Array This is an object that stores a fixed number of values ​​of the same type. In other words, an array is a numbered collection of variables. The variable in the array is called array element, and its position in the array is given index. For example, we need to store 50 different names; you must agree, it is inconvenient to create a separate variable for each name, so we will use an array. The numbering of array elements starts from 0, and the length of the array is set at the time of its creation and is fixed.

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

Essential resources for initial training

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

Basic Java packages

Below is a list of Java packages that a programmer should be comfortable with. It is recommended to get acquainted with them both through JavaDocs and using www.exampledepot.com. All packages are arranged in the recommended order for study. So:
  1. java.lang is 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 needed to work with collections: Collection, Enumeration, Set, List, Map, etc. and so on.
  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 weren'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.* - without these packages, working with XML is simply unthinkable

Resources to broaden your horizons

  • onjava.com - sooner or later all the news from the Java world ends up here
  • www.javaspecialists.eu - the resource is 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 RSS, as very interesting things about Java often pop up.

Java Libraries Everyone Should Know

Java doesn't end with just knowing what the JSDK can do. To feel comfortable you need to know about two dozen more third-party libraries used Java programmers everywhere. So, let's start with the main ones:
  • Commons Lang - what they “forgot” to include in the JDK
  • Commons Math is a great add-on for java.math
  • Commons Logging - logging must be competent. For System.out.println to output logs, novice programmers should cut off their hands after just a week of training.

Download

Java is a modern object-oriented programming language. A program written in Java can run on almost any computer. Knowing Java allows you to create powerful multimedia applications for any platform. Tens of thousands of programmers began learning Java using previous editions of this book. Now you! No matter what language you've programmed in before (and even if you've never programmed before), you'll quickly learn how to create modern, cross-platform apps.

  • Java World. Explore the Java platform, new features in Java 7, and modern tools development.
  • Building blocks. Learn to create powerful programs based on classes - well-isolated blocks of code.
  • Don't repeat yourself, but repeat. Learn to use existing code snippets in new programs.
  • Don't obsess, but obsess. Learn to use loops and conditionals for branching programs.
  • Be cool and stylish. Master correct style coding using classes and the principles of encapsulation, inheritance and polymorphism.
  • Experiment. Use variables and methods, arrays and collections. Program event processing. Create exception handlers.

Java is a wonderful language! I've been programming on it for many years. I especially like Java syntax- neat and well structured. Almost everything in it obeys simple rules. True, some rules look daunting at first glance, but this book is intended to help you understand them. So if you're planning to program in Java but don't want to read boring, thick tutorials, read this book and you'll find everything you need to get comfortable with your new programming language.

How to use this book

I really wish I could say “Open any page of the book at random and start writing Java code. Don't look back; you just need to fill in the blanks on the form.” In some cases this is true. You won't spoil anything if you start writing code in Java without knowing how to do it, so feel free to experiment with any examples.

However, we must honestly admit that the above statement is in most cases incorrect. If you don't see the whole picture, writing a correct program will be too difficult. This is true not only for Java, but for any programming language. If you enter code without knowing what it does, and then that code doesn't work, you'll be stumped.

Therefore, I divided the material in the book into small portions. Each portion is approximately one chapter. You can start reading from any chapter, and sometimes even from the middle of the chapter. I have taken great pains to ensure that the examples are clear without reference to other chapters and that the chapters are as independent of each other as possible. If a chapter introduces a complex concept that is explained in another chapter, I always provide a link to the other chapter.

In general, when reading this book, use the following tips.

  • If you already know something, you don't have to read about it.
  • If you're curious, don't be afraid to get ahead of yourself. You can always go back to a previous chapter to pick up where you left off or find an explanation for a concept you don't understand.

In some cases, making a decision can be difficult, so below is some advice on this matter.

  • If you already know what Java is and what this language is for.
  • If you can run a Java program and you don't care.
  • If you program for a living, but in some other language (for example, C++ or C#). If you have successfully reached Chapter 7, then you can already be considered a Java developer.
  • If you are familiar with the C language (but not C++).
  • If you are working in C++. Java differs slightly from C++ in its treatment of classes and objects.
  • If you program in Java for a living, contact me and help me write the next, 6th edition of this book.

This book is dedicated to the Java programming language, but a few words still need to be said about you, the reader of this book.

I'm assuming you have easy access to your computer. The codes given in this book as examples can be executed on almost any computer on which you can install operating system Windows, Mac, Linux or Unix. Even a computer from ten years ago (give or take a few years) will do, as long as it has a monitor, keyboard, mouse and, of course, a mouse pad.

I assume that you know how to work with standard elementsuser interface such as menus and dialog boxes. You don't have to be experienced Windows user, Linux or Mac, but you must be able to run the program, find the file, create a directory,
copy the file to the directory, i.e. perform basic operations. Most of the time you work through the examples in this book, you'll be typing and clicking.

On the rare occasions when you need to perform more complex operations, such as dragging or copying to the clipboard, I will tell you how to do it. However, please note that your computer may be configured with millions of different ways, and my instructions may not be completely accurate in all cases. Therefore, I recommend using the following technique: first of all, follow my instructions exactly; if something does not work out, try to adjust them in accordance with the specifics of your system; If this still does not achieve the desired results, check the instructions for your system.

I assume that you can think logically. Logical thinking is the main element of programming in any language, including Java. I hope this book will help you discover previously unknown logical abilities.

I make no assumptions about your previous program experience.mation (or lack thereof). While working on this book, I tried to do the impossible - to create a book that would be interesting for an experienced programmer and at the same time accessible to a person who has no programming experience. This means that I am not assuming that you have any programming experience or knowledge.

If you have never encountered the concepts of a loop or an array before, you can safely start reading this book. On the other hand, if you've seen them in other languages ​​(perhaps Visual Basic, C++, or COBOL), you'll find some interesting features in Java's implementation.

Java developers took the best ideas from the concept of object-oriented programming, simplified them, and based on them created a powerful technology for solving algorithmic problems. Java offers many new features that encourage creative programming. Many of them will seem quite difficult to you at first, but over time they will become quite natural to you. Either way, you'll enjoy programming in Java.

Object-oriented programming

One day at three o'clock in the morning I had a dream about a history exam I failed in college. The teacher told me with a hypnotizing intonation: “You have two days to prepare for the exam, but you will forget that you need to prepare. You will feel guilty, but you won't remember why. Guilt will depress you, depress you, depress you..."

Suddenly the phone rang and I woke up with a start. I don't like dreams about a history exam, but waking up to phone call I don't like it even more. At first, I wanted to sharply remind the caller to first ask what time it was in my time zone, but I dropped the phone on the floor and forgot to do so. When I finally found the phone and picked it up, the person on the other end of the line said he was a reporter for a newspaper. He received an assignment to write an article about Java and wants me to tell him in a nutshell what it is.

I told him a few words about Java (deciding that I would get rid of him faster this way than if I caused trouble) and fell asleep again. In the morning I could no longer remember what I told him and whether I dreamed it. But, as it turned out, I was not dreaming, because a few days later I received a copy of the newspaper, in which I was struck by a headline written in large letters: “Barry Bird says Java is a wonderful object-oriented language.”

Objects and classes

An object-oriented language uses objects and classes to organize data.

Let's say you need to write a program to support the construction of cottages for a new housing association. The cottages are slightly different from each other. Parameters such as facade color, interior decoration, kitchen style, etc. may be different. In your object-oriented computer program, each cottage is an object.

However, the cottages are not only different from each other. They have the same set of changeable parameters, for example, each cottage is characterized by the color of the facade, interior design, kitchen style, etc. An object-oriented program requires a master list containing all the characteristics of the cottages, i.e. objects. Such a list is called a class.

Perhaps it would be better to call this style of programming not object-oriented, but class- and object-based programming. It is no coincidence that I placed the word “classes” in first place, because the concept of a class is more important than the concept of an object. Imagine a construction site. In its corner, in the middle of a large puddle, there is a trailer in which there is a foreman’s office and a drawing of the cottage. A blueprint is a class because it contains comprehensive information about each cottage and a list of changeable parameters.

The analogy between a drawing and a class is not limited to the presence of a list of parameters. The similarity between them is much deeper. The drawing is created once. On its basis, the contractor builds, for example, ten cottages...



tell friends