Hello, ladies and gentlemen, last time we started to talk about Android. But before we get to Android, we need to introduce Java to lay a foundation for Android. Stop gossiping and return to the truth. Let’s Talk Android!
“Why do you want to introduce Java?” I had not even started the introduction when the interviewer asked questions. Ha ha! Don’t worry, I will introduce the reasons.
Android is a mobile operating system, mainly used in mobile terminals, that is, mobile phones that we often use. At the moment, the market share of this system is so high that I’m sure our viewers have phones that use this operating system. Talk Android focuses on how to develop applications on the system. Just as we use C to develop programs on Linux systems, we use Java primarily to develop applications on Linux systems, which is why we introduced Java in the first place.
Java is an excellent language, although not as long-lived as C, but it has something that C cannot match: object orientation. This is one of the reasons why Java is popular. In addition, it also has a very good portability, which makes C language is also very good. Java’s good mobility is built on the Java virtual machine. The Java programs we write are first compiled into Java bytecode, or.class files, which can then be run in the Java Virtual Machine, which runs on our operating system.
With that said, let’s take a look at what a real Java program looks like. Let’s use the classic Hello World example. Make sure you have JDK and Eclipse installed on your computer and that the software version is not too low. As for how to install I believe you can fix their own. Create a new Java project in Eclipse and create a file called HelloWrold. Java. Type the following code into the file:
public class HelloWorld {
public static void main(String args[])
{
System.out.println("Hello World"); }}Copy the code
To run the program, click the Run icon in Eclipse or press Ctrl+F11. The running results of the program are as follows:
Hello World
Copy the code
Let’s take a quick look at the program. In this program we define a class called HelloWorld, and in this class we define a Main function that prints HelloWorld using println. This is what we see in the program’s results. The functions here and the Main function are similar to those in C, but we’ll talk more about what a class is in the future.
Hello World is a Java version of Hello World. It is a Java version of Hello World.