Getting started with Java programming. What is Java? Where to start learning the Java programming language

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

Do you want to learn to program? A reasonable thought: such a skill will most likely not be superfluous. True, this will require a little work. We present to your attention a series of lessons that will allow you, in the foreseeable future, not only to get an idea of ​​what programming is, but also to learn how to create programs of non-trivial purpose and size.

There are several ways to learn programming.

The first and, perhaps, the most common is from books. All you need is to find a suitable book and read it sequentially, page by page, and complete all the suggested exercises (if any). If the book is worthwhile (preferably from the authors of a technology or programming language), then this method, sooner or later, gives excellent results: you will know and understand most of the necessary material. But this method is long and of little use to those who are just starting to program and whose experience is limited to the most primitive information that he or she received in school or at work. You need to have a fair amount of patience, perseverance (often even stubbornness) in order to “wade through” a mass of new concepts, concepts and unusual terminology. Still, books are good for those who have at least basic knowledge of the subject and do not stop at every line just to simply understand what is being said.

In addition, without experience, you are unlikely to choose exactly the book that will provide the necessary knowledge. The book market is flooded with waste paper of high printing quality. But the value of most of these manuals, textbooks and books is more than doubtful. Sometimes a small and inconspicuous book at a ridiculous price turns out to be immeasurably more useful than a luxurious edition with excellent graphics on coated paper (and a price ten to fifteen times higher).

The second way is courses with an experienced teacher. The ideal option is when you and the teacher work as a pair: the teacher explains and shows, you try to repeat and develop. You can stop at any time and clarify what you don’t understand. The teacher himself can adjust the pace of learning in accordance with your successes or failures. It is somewhat worse when there is only one teacher, and there are several students. Usually this method gives excellent results, provided that the group is not very large (say, 3, maximum 5 people) and the level of training of all students is approximately the same. If you have the opportunity and finances allow you to pay for such courses, it is better to take advantage of them.

Unfortunately, this method is not available to residents of small settlements where there are no training centers, as well as to those whose income level is not high enough to afford such a “luxury”. Of course, it happens that an employer sends its employees to training courses at its own expense, but it depends on your luck.

The third way (and let’s say right away – the best of all) is to work alongside an experienced mentor. Books are books, courses are courses, and personal example, especially in real (“combat”) conditions, is simply a godsend. Sometimes it’s enough to just sit and observe, asking questions if necessary. If the mentor is a sane person (and real professionals, as a rule, are sane and friendly people), then in a few weeks you will receive something that will allow you to start working on tasks of average complexity and not constantly consult reference books in search of basic things. During this period of time, you, of course, will not become a professional, but you will not be a complete beginner either. Of course, during the learning process, you need to remember to have a sense of proportion and not “bother” a busy specialist with very basic questions: first you need to look for the answer yourself. This way you will receive the necessary knowledge and skills almost free of charge and in a very short time.

But what to do if this method is not feasible, but you want to learn? Should I really take a risk and turn to books? Still, the situation is not hopeless. We decided to prepare a small training course for beginners. This course contains only the essentials, but provides enough understanding of the subject and skills that will allow you to move forward on your own. Of course, the absence feedback there will be a certain obstacle between us and you, but we hope that with some effort you will be able to learn something. In any case, we hope that after studying this course in full, you will be able to move forward on your own. Of course, we don’t promise you an easy life, but we will try to help. Before moving on to the course itself, read and consider a few recommendations:

  • information Technology You can, of course, study without a computer, but you must admit that with a computer it is still more comfortable and practical; therefore a computer is necessary. Any model not older than 5 years will do. There are no special requirements for the hardware filling or configuration, but remember simple rules - the more RAM, the better, the better the monitor, the more convenient. In a word, don’t skimp on trifles, but don’t waste your money either. A typical laptop that costs around $500 or a little more is about right.
  • Any modern software must be installed on the computer operating system(which one is absolutely not important): Windows, Linux, MacOS, FreeBSD, etc. Since the vast majority of users have an operating system on their computer Windows family(one version or another) from Microsoft, then in our further presentation we will focus primarily on it. You must be able to work on a computer (use a keyboard, mouse, USB devices, printer, connect to the Internet, etc.). Skills in working with text editors or spreadsheets. In general, remember that the programmer's main tool (after the head, of course) is the keyboard, so if you have difficulty finding the spacebar on the keyboard, then you will have big problems. Only practice can help here.
  • regarding what is required for this course software, we'll talk about it next time. We only note that to receive it you need access to the Internet. If you are reading these lines, then you already have such a way out.
  • the course is designed for regular work. Resist the temptation to skip what seems elementary to you and jump to the next topic: this is fraught with unpleasant consequences, because... you may miss a subtle point or an important detail.
  • information technologies are oversaturated with specific terminology, mainly of English origin; Almost all valuable documentation is written in English language. So it’s useful to arm yourself with at least some kind of dictionary (any electronic one will do, even not the most powerful one) - gradually you will get used to it and learn most of the necessary phrases and terms.
  • The duration of each lesson is from 15 to 40 minutes. Each lesson must be studied completely: from cover to cover. We tried to make the course as clear as possible, but without water and long discussions. Examples program code must be typed and checked on your computer (this, however, is not always feasible if a large issue is being considered and the discussion stretches over several classes, but sooner or later you should - even must - get the result that it should be).
  • if you are tired, rest for a day or another. No catastrophe will happen. But not more. Don’t try to catch up in a day with what you had to study for two months - you will get tired, confused and, in the end, disappointed in yourself or in what you were doing. If there is a break, then catch up slowly. The main thing is not to remember, but to understand. What is understood is remembered by itself. So no cramming.
  • Keep a notepad or notebook and mark in it what you think is important. There is no need to take notes - write down only what you - exactly you - found interesting, stupid, funny. It could be a phrase, a piece of code, a quote, a cartoon—anything. Review earlier entries periodically; this will help you remember what you have learned.

Our approach is closest to the third way of learning - i.e. training with a mentor. Our principle is simple: show and explain key details. We will not discuss simple and obvious things for a long, boring and tedious time (if necessary, you will find enough information about them in books, documentation, and specialized forums). We will gradually develop a small application that will show you the work professional programmer. But “small” does not mean “simple” - far from it! To get results you will have to work hard. But don’t be afraid - the result is worth it. The main thing is to want and follow your goal, overcoming hills and holes along the way.

Now let's take a break. For the next lesson, prepare your computer for work - make sure that there is at least 1 GB of free disk space on your hard drive; if the RAM is less than 1GB, then find out whether it can be increased and be sure to increase it (with RAM You shouldn’t save at all: if your computer allows you to install 4 GB, then install that much; Believe me, this pays off in terms of work comfort and time savings): we have a little tedious, but necessary work to install several programs. So see you later!

Just recently we held a webinar and us, as owners online courses in Java, they asked me to tell you how you can learn Java on your own. We decided to write several proven ways on how to learn Java or, in general, how to learn programming from scratch.

So, you are determined to become a Java programmer. And immediately you have a lot of questions: “Where to start learning Java? How to choose the right training program? How to learn Java and gain work experience?

Today there are many ways to learn anything, and programming is no exception. In addition to the classic methods - self-study and offline programming courses - there are currently many online Java courses and trainings, both paid and free.

We have highlighted the most popular ways to learn programming on your own.

So, here are some ways to learn Java:

1. Self-study.

AdvantageThis method of training is that you yourself can plan absolutely all aspects of your training - what, where, how and when to teach.

DisadvantageThe thing is that not everyone has the willpower to independently master a huge amount of material, read a bunch of books, gain enough practical experience and not give up everything at the beginning of the journey. In addition, everyone will have doubts: “Am I going the right way, am I doing everything right?”

2. Free online course.

Advantage this method training is, of course, the cost - it simply does not exist, all materials are free and this is a huge plus.

FlawAnother thing is that, as practice shows, not everyone has the motivation to complete an online course in Java or any other language, and many quit without actually even starting to learn.


3. Offline training.

AdvantageOne of the benefits of learning Java programming is that you can communicate with the teacher live, in addition, there will already be a small community of your colleagues with whom you can discuss issues that have arisen and their solutions.

Flaw- this is that, as a rule, such courses are taken at a time that is not the most convenient for mastering the material - in the evenings, and the time spent traveling back and forth can be quite significant. In addition, the cost of the course includes the cost of renting premises, equipment and materials for conducting classes.



4. Personal coaching/mentoring.

AdvantageThis way to learn Java or another programming language is that you can find yourself an experienced mentor who will work with you personally, prepare individual tasks especially for you, do a code review of your code and point out exactly your mistakes and gaps in knowledge.

The only one disadvantageIt will be that the time of an experienced mentor is worth a lot, and finding a person who agrees to give you so much attention is not always easy.


5. And finally, training in the company.

There is an option to take some training courses at an IT company, where, most likely, you will work on a project that is quite close to real conditions, plus there is a high probability of getting a job at this company after successfully completing the course. However, the competition for such trainings is often very high and you must already have solid knowledge in order to be accepted.


In any case, you can learn Java or learn programming from scratch, just find a way that suits you.

Good luck to you in all your endeavors! If you know some other methods and have been convinced in your own practice that they work, write to us. We are always ready to communicate with people who are open to dialogue.

Barry Bird "Java for Dummies" Williams, 2013, 5th edition, 363 pp. (8.23 mb. djvu)

About Java.

For dummies, it’s the same as saying programming. It sounds trivial, but Java is by far the most popular programming language. More people program in it than in C++ and C# combined. Start learning Java if you want to learn programming and you can't go wrong. The code written in this programming language is cross-platform. It will run on any device and under any operating system where the Java virtual machine (JRE) is installed - “Write once, run everywhere.” The book “Java for Dummies” is designed specifically for them.

About the book.

If you've never learned programming and don't know about OOP, don't worry, Barry Bird is a good explainer. At a minimum, the basic concepts are objective oriented programming And basic knowledge in the Java language you are guaranteed. Subject to careful study of the book material and completion of tasks in the form of code examples. In the guide, the author will talk about the history of the Java language, its basic concepts, advantages and disadvantages, existing versions and their differences, the tools necessary for coding and executing ready-made programs (JDK, JRE, Eclipse).

Learn the basics: grammar (syntax) of the language, the concept of API classes (standard libraries), write your first program. For initial stage learning Java this book is quite enough. If you have the courage to finish reading it and complete at least part of the tasks, then you can begin to study more voluminous ones. The path to perfection has a beginning, but has no end.

Book table of contents
About the author 13
Introduction 15
How to use this book 15
Conventions Used in Book 15
What you may not read 16
Some guesses 17
Book 18 structure
Part I Java Basics 18
Part II. Creating a Java 18 Program
Part III. Object-Oriented Programming 18
Part IV. Programming Best Practices 19
Part V. Magnificent Tens 19
Part VI. Applications 19
Pictograms used in book 19
What's next 20
We are waiting for your feedback! 20

Part I Java Basics 21

Chapter 1. Introduction to Java 23
What can you do with Java 24
Why write programs 25
A little history 25
Object-Oriented Programming 28
Object-oriented languages ​​28
Objects and classes 30
Benefits of the Object Oriented Approach 31
Visual representation of classes and objects 32
What's next 33

Chapter 2. Software development 35
Quick start 35
What should be installed on your computer 37
What is a compiler 38
What is the Java Virtual Machine 40
Development process 45
Integrated Development Environment 46

Chapter 3. Core Java Components 49
Let's talk on Java language 49
Grammar and common names 50
Words in a Java 51 program
Your first Java 53 program
How your first program works 54
Classes 54
Methods 55
Main method of program 57
How to tell the computer to perform a desired operation 58
Curly braces 60
Don't say “No comment...” 62
Adding comments to code 63
Don't be too hard on ol' Barry 66
Using Comments to Experiment with Code 66

Part II. Creating a Java Program 69

Chapter 4. Variables and values 71
Changeable variable 71
Assignment operator 74
Types of values ​​and variables 75
Text display 77
Numbers without decimal point 78
Initialization on declaration 79
Java 80 primitive types
Type char 81
Type boolean 82
Reference types 83
Import announcement 86
Creating New Values ​​Using Operators 87
You can initialize once, but assign many times 89
Increment and Decrement Operators 89
Assignment Operators 93

Chapter 5. Control instructions 95
Making a Decision Using an If Statement 95
Guess the number 96
Entering text from the keyboard 96
Random number generation 98
if instruction 98
Double equal sign 100
Blocks 100
Indentation in if 101 statement
Broken fork (if without else) 101
Conditions with comparison operators and logical operators 102
Comparison of numbers and symbols 102
Comparison of objects 103
We import everything at once 105
Logical operators 106
How “zero” differs from “nothing” 108
Conditions in parentheses and parentheses in conditions 109
Nesting if statements 111
Switch switch 113
Select option 113
Don't forget to insert break! 115
String argument - new in Java 7 117

Chapter 6. Cycles 119
while loop 119
Loop for 122
For 124 loop structure
Premiere of the hit “Al in the Rain” 125
Cycle do 126
Reading one character from the keyboard 129
File manipulation 130
Declaring a variable in block 130

Part III. Object-oriented programming 131

Chapter 7. Classes and objects 133
Class Definition 133
Open class 135
Declaring Variables and Creating Objects 135
Initializing a variable 138
One program - many classes 139
Defining a method in a class 139
Score displaying itself 140
Method header 141
Passing parameters to a method and receiving a value from the method 142
Passing a value to method 144
Return value from method 145
How to make numbers look nice 147
Access modifiers 151
Correct programming style 152
How to make a field inaccessible 154
Checking Rules Using Access Methods 156

Chapter 8. Code reuse 157
Class Definition 158
Class defining employee 158
Proper Use of Class 159
Creating a payment receipt 161
Working with files (short digression) 162
Storing data in a file 162
Copy and paste code 163
Reading from file 164
Where did my file go? 166
Adding Folder Names to a File Name 166
Line by line reading 167
Inheritance 169
Creating a Derived Class 171
Using Derived Classes 174
Type matching 175
Using the PartTimeEmployee Class 176
Override existing methods 177
Annotations 179
Calling methods of base and derived classes 179

Chapter 9 Constructors 181
Constructor Definition 181
What is temperature 182
What is a temperature scale 182
So what is temperature? 183
What can you do with a temperature of 185
Finding the right constructor 186
Some things never change 189
Base class constructor in derived class 190
Advanced temperature class 190
Constructors of derived classes 191
Use of advanced temperature class 192
Default constructor 193
The constructor can not only fill in fields 194
Java AP 196 Classes and Methods
Annotation @SuppressWarnings 198

Part IV. Advanced Programming Techniques 199

Chapter 10. Correct Use of Variables and Methods 201
Definition of class 201
Another way to make numbers beautiful 202
Using the Player 203 class
Nine Constructor Calls 205
Graphical User Interface 205
Let's throw an exception to another method 207
Static fields and methods 207
Why so much static 209
Static initialization 210
Displaying overall team statistics 210
Static import 212
Beware of static! 213
Let's experiment with variables 214
Variable in its place 215
Variables in different places 217
Transfer of parameters 219
Pass by value 219
Returning result 221
Passing by reference 221
Returning an object from method 223
Epilogue 224

Chapter 11. Arrays and Collections 225
How to arrange objects in a row 225
Creating an array in two steps 227
Saving values ​​228
Tabulostops and others Special symbols 230
Initializing array 230
Advanced for loop 231
Search 233
Arrays of objects 236
Using the Room 237 class
Another way to decorate the numbers 240
Ternary conditional operator 241
Arguments command line 241
Using Command Line Arguments in Code 242
Checking the number of command line arguments 244
Collections 245
Collection classes 246
ArrayList Class 247
Using Generic Types 250
Checking if there is still data 250

Chapter 12. How to keep a good face when playing poorly 253
Exception handling 254
catch block parameter 258
Exception types 259
Who should catch exception 261
catch block with multiple exception types 267
Let's not be overly cautious 267
Restoring program operation after an exception 268
Our friends are good exceptions 269
Handle the exception or pass it on 270
finally block 274
Closing files 276
How to close file 276
Resources in try block header 276

Chapter 13. Area of ​​visibility 279
Access modifiers for class members 280
Classes, access and program parts 280
Classes and Class Members 281
Rules for accessing class members 281
Example with a picture in frame 283
Folder structure 285
Creating a Frame 286
How to change a program without changing classes 287
Default access 289
How to get into package 292
Protected access 292
Including a non-derived class in the same package 294
Class access modifiers 295
Open classes 296
Not open classes 296

Chapter 14. Responding to Keyboard and Mouse Events 299
Mouse click response 299
Events and 301 event handling
Java 302 Interfaces
Streams 303
Keyword this 304
Body of the actionPerf ormed() method 305
Version ID 305
Responding to other events 306
Internal classes 311

Chapter 15. Applets 315
Example of a simple applet 315
Executing Applet 316
Open class 317
Java API Classes 317
Animated applet 318
Methods used in Applet 319
Contents of applet 320 methods
Reacting to Events in an Applet

Stava 16. Database Connection 325
JDBC and Java DB 325
Creating Database Records 326
Using SQL Commands 328
Connecting and disconnecting a database 328
Data Extraction 330

Part V Magnificent Tens 333

Chapter 17. Ten ways to avoid mistakes 335
Proper use of letter case 335
Exit from block switch 336
Comparing two values ​​336
Adding an element to GUI 336
Adding Event Receivers 337
Defining Constructors 337
Fixing non-static links 337
Respect array boundaries 337
Pointers to nu 11 338
Help virtual machine Java find classes 338

Chapter 18. Ten websites dedicated to Java 341
Websites for this book 341
Java 341 Sites
News, reviews, examples of codes 342
Job 342
Websites for everyone 342

Part VI. Applications 343

Appendix A: Installing the IDE 345
Download and Install JDK 345
Download and Install Eclipse 349
Configuring Eclipse 351
Appendix B: Using Eclipse 353
Working with examples from book 353
Creating your own project 355
Subject index 359

Download the book for free 8.23 ​​MB. djvu

Java for dummies. Video

Java is a programming language. It allows programmers to write computer instructions using commands in English instead of writing in digital code. Java is a high-level programming language because its code is easy to write and read. Like regular languages, Java has a set of rules that determine how instructions are written. These rules are called "syntax". The finished high-level Java code is translated into machine-readable digital code that is executed by the computer.

Who created the Java programming language?

Java was created in the early 90s by a team of programmers led by James Gosling for Sun Microsystems. Java was originally created for development in mobile devices Oh. But when Java 1.0 was released in 1996, the language's main focus shifted to use on the Internet. Java brought more interactivity with users by allowing developers to create animated pages. Over time, Java has become a successful programming language both for the Internet and in other areas.

20 years later, Java is still an incredibly popular language with over 6.5 million developers worldwide.

Why choose Java?

Java was created based on several key principles:

1. Ease of use.

The basics of Java are taken from C++. Despite the power of C++, the language has a rather complex syntax and is not adequate for all Java requirements. Over the years, Java has improved upon the ideas of C++, making it a powerful yet simple programming language.

2. Reliability.

Java minimizes fatal errors caused by programmer errors. Thus, object-oriented programming was introduced. Once data and actions on it were collected in one place, the reliability of the Java language increased.

3. Security.

Since Java was originally designed exclusively for mobile devices that would exchange data over networks, security was at the highest level from the very beginning. On this moment Java is probably the safest programming language.

4. Platform independence.

Programs written in Java were expected to work no matter what platform they were run on. Java was originally a portable language for which neither the operating system nor the computer hardware is important.

The Sun Microsystems team has successfully combined key principles. Java owes its popularity to its reliability, security, ease of use, and portability.

Where to start learning Java?

1. Install JDK

To start programming in Java, you need to download and install the Java development Kit (Java Development Kit, JDK). Once you install the JDK on your computer, you can immediately start writing your first program.

2. Select IDE

IDE - integrated development environment. There are several different tools available for developing Java applications. Their goal is to help you write a Java application. There are several Java development environments, but we recommend NetBeans - ideal for beginners. You can focus on just a couple of NetBeans commands to achieve your goals.

3. First steps

Inevitably, the first program of any beginner is simple program"Hello World", which simply displays this name. This simple program will show you how to compile, run, and run an application in a development environment like NetBeans.

After creating your first program, it’s time to start learning the language using lessons for beginners, for example, with courses -. They will guide you through the different stages of learning Java syntax.

Or, if you're the type who likes to dive right in, you can start your training more ambitiously. The more you plunge into the depths of the language, the more you will learn. This can be done by immediately starting to write a Java application.

4. How to choose your first Java application

There is a lot of theory behind any programming language, including Java. You will have to learn the syntax of the language and how the entire application is assembled. But we think it's more important to remember that Java is there to be used. There are an endless number of applications that can be created using it. And if you choose from the very beginning what kind of application you want to create, it will dictate the path you take to learn Java syntax.

Let's say you don't know anything about how to write Java programs, but you decide to start with a simple calculator. You already know what a calculator is and what it looks like. There are no questions about the design, there are questions about the implementation. You will learn that in the process of creating a program you will constantly ask yourself questions in the spirit of “How to do this?..” And there will be many of them. But the more questions you ask, the more you will learn about the language.

For example, the first thing you'll probably think of is the GUI (graphical user interface), which is simply how the program will appear on the screen while the application is running. You intuitively feel what the program should look like based on your experience working with ready-made applications. First, the main program window, where all the calculator’s control elements will be located. Buttons for numbers, for operations (addition, multiplication, etc.). An element for displaying the result of calculations. And so on.

This roughly outlines your first set of questions. How to make an application window? How to add buttons to it? Which element should I use to display the results? This is where learning the Java language comes in. You start looking for answers on how to create an application in Java, what elements to use for the application window, what elements to use for buttons, etc. You will always find answers on websites with Java lessons, in books, and on programmer forums.

The most important thing is to do the first work program. Don't think about doing everything optimally right away. This will come with experience as you gain confidence in Java programming. For now, the only goal is to get the Java code to compile and run. Even if the program doesn't work as intended, it will be a start to learning.

5. Another way

If you feel that you won’t be able to cope with learning a programming language alone, especially one as serious and large-scale as Java, try taking specialized courses that teach the basics of programming. For example,



tell friends