前段时间我们解释了什么是 JavaScript(what is JavaScript),因为互联网上的很多用户可能对它没有基本的了解。今天,我们决定谈谈Java,一种与 JavaScript 不同的流行编程语言。
Java 编程语言
这可能会让您感到惊讶,也可能不会感到惊讶,但这是事实。尽管如此(Nevertheless),Java编程语言非常流行,我们预计它会在未来几年保持这种状态。这是因为它是一种在世界各地使用的多用途语言。
我们应该指出,Java被认为是一种高级编程语言,因为它可以被人和计算机阅读。它严重依赖基于英语的命令,这也是它获得大量追随者的原因之一。
与英语(English)一样,Java也有一套规则,每个程序员都必须遵守。有问题的规则称为Syntax。代码是用英语(English)编写的,供人类理解,然后在执行时转换为数字供计算机理解。
该语言背后的理念是WORA,这意味着,一次编写(Write Once),随处运行(Run Anywhere)。它只是意味着编译后的Java代码应该可以在任何支持平台上运行,而无需重新编译。
阅读(Read):什么是 R 编程语言(What is the R programming language)?
Java的创造者是谁?
Java最初是由Sun Microsystems的(Microsystems)James Gosling领导的团队在90 年代创建的。对于那些没有跟上技术收购的人来说,Sun Microsystems现在归甲骨文(Oracle)所有,Java也是如此。
在语言的早期开发中,该团队专注于为移动设备创建工具,但是当1996 年发布Java 1.0 版供公众使用时,这种情况很快发生了变化。如今,该语言被大量用于事物。例如,它用于 Web 开发、为移动设备创建视频游戏等等。
多年来,Java经历了多次更新,在撰写本文时,它是第 15 版,远远优于 1996 年的原始版本。
阅读(Read):Netbeans IDE 是一种新时代的编程语言。
为什么你现在应该使用 Java
可靠性:多年来对Java的最佳补充之一就是所谓的面向对象编程。引入它是为了限制程序员在犯错时所犯的错误,即使是最好的程序员也会发生这种情况。今天,Java语言非常可靠,因此很受欢迎。
安全性:这种语言是从头开始构建的,并考虑到了安全性。这是因为Java最初是为最终将通过无线网络交换信息的移动设备设计的。在撰写本文时,我们相信Java是世界上最安全的编程语言之一。
易用性:对于大众喜爱的编程语言,它应该易于使用,而这正是Java带来的。现在,Java的基本原理源自 C++,但它们并不完全相同,因为 C++ 可能相当复杂,尤其是对于新用户而言。尽管如此,尽管 Python 易于使用,但我们认为Python在这方面领先一步。
适用于所有平台:如果开发人员和程序员被迫使用单一操作系统来完成工作,那么他们使用的语言就不够好。值得庆幸的是,我们可以肯定地说Java可以在多个平台上出色地工作,这包括Windows、Linux、Mac等。
Java 代码示例
与大多数编程语言一样,您应该从Hello World开始,而这正是我们现在要做的。以下代码示例是如何完成它:
public class MyClass { public static void main(String[] args) { System.out.println("Hello World"); } }
评论呢?是的,您可以在代码中留下评论。让我们看看如何完成这项任务:
// This is a comment System.out.println("Hello World");
The overall code, then, should look like this:
public class MyClass {
public static void main(String[] args) {
// This is a comment
System.out.println("Hello World");
}
}
这些只是基础知识,但随着时间的推移,我们相信您会像其他成千上万的人一样成为Java编码专家。(Java)
我们希望您找到适合初学者的帖子,易于理解。
What is Java Programming language? Code examples
A while back we explained what is JavaScript since a lot of users on the internet might not have a basic understanding of it. Today, we have decided to talk about Java, a popular programming language that is not the same as JavaScript.
Java Programming language
That may or may not surprise you, but it is the truth. Nevertheless, the Java programming language is very popular and we expect it to be this way for multiple years to come. This is because it is a multipurpose language that is used everywhere around the world.
We should point out that Java is considered a high-level programming language because it can be read by both humans and computers. It relies heavily on English-based commands, which is one of the reasons why it has garnered a strong following.
In the same way as English, Java comes with a set of rules that each programmer must follow. The rules in question are known as Syntax. The code is written in English for humans to understand, and then when executed, it is converted to numerals for computers to understand.
The idea behind the language is to WORA, which means, Write Once, Run Anywhere. It simply means that a compiled Java code should run on any supporting platform without the need for recompilation.
Read: What is the R programming language?
Who are the creators of Java?
Java was originally created in the 90s by a team lead by James Gosling at Sun Microsystems. For those who haven’t been keeping up with tech acquisitions, Sun Microsystems is now owned by Oracle, and that goes for Java as well.
In the early development of the language, the team was focusing on creating a tool for mobile devices, but that quickly changed when version 1.0 of Java was released for public consumption in the year 1996. These days, the language is used for a plethora of things. For example, it is used for web development, the creation of video games for mobile devices, and much more.
Over the years, Java has seen several updates, and at the time of writing, it is at version 15, which is far superior to the original release back in 1996.
Read: Netbeans IDE is a new-age Programming Language.
Why you should use Java right now
Reliability: One of the best additions to Java over the years, is something known as object-oriented programming. It was introduced to limit errors made by programmers whenever they make mistakes, and this is something that happens even with the best of the bunch. Today, the Java language is very reliable, hence its popularity.
Security: This language was built from the ground-up with security in mind. The reason for this was because Java was originally designed for mobile devices that would eventually exchange information over a wireless network. At the time of writing, we believe Java is one of the most secure programming languages in the world.
Ease of use: For a programming language to be loved by the masses, it should be easy to use, and that is exactly what Java brings to the table. Now, the basic principles of Java have derived from C++, but they are not exactly the same since C++ can be quite complex, especially for new users. Still, despite its ease of use, we believe Python is a step above in this regard.
Works on all platforms: If developers and programmers are forced to use a single operating system to get work done, then that language they’re using is not good enough. Thankfully, we can say for certain that Java works wonderfully across multiple platforms, and this includes Windows, Linux, Mac, and more.
Java Code examples
As with most programming languages, you should begin with Hello World, and that is exactly what we’re going to do right now. The following code example is how to get it done:
public class MyClass { public static void main(String[] args) { System.out.println("Hello World"); } }
What about comments? Yes, you can leave a comment in your code. Let us look at how to accomplish that task:
// This is a comment System.out.println("Hello World");
The overall code, then, should look like this:
public class MyClass {
public static void main(String[] args) {
// This is a comment
System.out.println("Hello World");
}
}
These are just the basics, but as time goes by, we are sure you will become an expert at coding in Java, like thousands of others.
We hope you find the post for beginners, easy to understand.