Домой United States USA — IT Java tutorial for beginners: Write a simple app with no previous experience

Java tutorial for beginners: Write a simple app with no previous experience

311
0
ПОДЕЛИТЬСЯ

This is an in-depth java tutorial for beginners. Learn what Java is, how to get started, and how to build basic apps using key concepts!
Java is one of the most in-demand programming languages in the world and one of the two official programming languages used in Android development (the other being Kotlin). Developers familiar with Java are highly employable and capable of building a wide range of different apps, games, and tools. In this Java tutorial for beginners, you will take your first steps to become one such developer! We’ll go through everything you need to know to get started, and help you build your first basic app.
Java is an object-oriented programming language developed by Sun Microsystems in the 1990s (later purchased by Oracle).
“Object oriented” refers to the way that Java code is structured: in modular sections called “classes” that work together to deliver a cohesive experience. We’ll discuss this more later, but suffice to say that it results in versatile and organized code that is easy to edit and repurpose.
Java is influenced by C and C++, so it has many similarities with those languages (and C#). One of the big advantages of Java is that it is “platform independent.” This means that code you write on one machine can easily be run on a different one. This is referred to as the “write once, run anywhere” principle (although it is not always that simple in practice!).
To run and use Java, you need three things:
The Java Virtual Machine ensures that your Java applications have access to the minimum resources they need to run. It is thanks to the JVM that Java code is so easily run across platforms.
The Java Runtime Environment provides a “container” for those elements and your code to run in. The JDK is the “compiler” that interprets the code itself and executes it. The JDK also contains the developer tools you need to write Java code (as the name suggests!).
The good news is that developers need only concern themselves with downloading the JDK – as this comes packed with the other two components.
If you plan on developing Java apps on your desktop computer, then you will need to download and install the JDK.
You can get the latest version of the JDK directly from Oracle. Once you’ve installed this, your computer will have the ability to understand and run Java code. However, you will still need an additional piece of software in order to actually write the code. This is the “Integrated Development Environment” or IDE: the interface used by developers to enter their code and call upon the JDK.
When developing for Android, you will use the Android Studio IDE. This not only serves as an interface for your Java (or Kotlin) code, but also acts as a bridge for accessing Android-specific code from the SDK. For more on that, check out our guide to Android development for beginners.
For the purposes of this Java tutorial, it may be easier to write your code directly into a Java compiler app. You can download these for Android and iOS, or even find web apps that run in your browser. These tools provide everything you need in one place and let you start testing code.
If you’re new to Java development, then you may understandably be a little apprehensive. How easy is Java to learn?
This question is somewhat subjective, but I would personally rate Java as being on the slightly harder end of the spectrum. While easier than C++ and is often described as more user-friendly, it certainly isn’t quite as straightforward as options like Python or BASIC which sit at the very beginner-friendly end of the spectrum. For absolute beginners who want the smoothest ride possible, I would recommend Python as an easier starting point.
C# is also a little easier as compared with Java, although they are very similar.
Also read: An introduction to C# for Android for beginners
Of course, if you have a specific goal in mind – such as developing apps for Android – it is probably easiest to start with a language that is already supported by that platform.
Java has its quirks, but it’s certainly not impossible to learn and will open up a wealth of opportunities once you crack it.

Continue reading...