top of page
Search
  • Writer's picturetechwriting

5 Things To Know About Java Programming

Java is the most popular and the most used programming language by the programmers and developers around the world. Java is object-oriented programming language and its syntax looks like C++ programming language. Why this language is the most used world's programming language and why it is so powerful, you can find incredibly understanding answers in my new blog post. So make you comfortable and keep reading!


1. About Java Programming language

Java is a general-purpose programming language that is class-based, object-oriented and designed to have as few implementation. It is intended to let application developers write once, run anywhere, meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. The syntax of Java is similar to C and C++ programming language, but it has fewer low-level facilities than either of them.


As of 2019, Java was one of the most popular programming languages in use according to particularly for client-server web applications, with a reported 9 million developers. Java was originally developed by James Gosling at Sun Microsystems back in 1995. The latest versions are Java 13, released in September 2019, and Java 11, a currently supported long-term support (LTS) version, released on September 25, 2018 by Oracle.


2. Java Syntax

The syntax of Java is largely influenced by C++ programming language. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object-oriented language. All code is written inside classes, and every data item is an object, with the exception of the primitive data types, which are not objects for performance reasons. Java reuses some popular aspects of C++, such as the printf method.


Unlike C++, Java does not support operator overloading or multiple inheritance for classes, though multiple inheritance is supported for interfaces.


Source files must be named after the public class they contain, appending the suffix .java, for example, HelloWorldApp.java. It must first be compiled into byte code, using a Java compiler, producing a file named HelloWorldApp.class. Only then can it be executed, or launched. The Java source file may only contain one public class, but it can contain multiple classes with a non-public access modifier and any number of public inner classes. When the source file contains multiple classes, it is necessary to make one class, introduced by the class keyword and public keyword.


The keyword public denotes that a method can be called from code in other classes, or that a class may be used by classes outside the class hierarchy. The class hierarchy is related to the name of the directory in which the .java file is located. This is called an access level modifier. Other access level modifiers include the keywords private and protected.


Code Example:


HelloWorld Example Code

3. Allocating Memory

This tip is particularly useful for those who switch from C, C++ to Java. The memory allocation in Java using the ‘new’ keyword is a necessity as Java is a dynamic programming language. C, C++ does not explicitly have this feature, therefore you must take care while handling array and object declaration in Java. Not using the ‘new’ keyword will show a null pointer exception in the code.


Example: int array = new int [5];

Note the difference in array declaration in Java and C or C++.


4. Java Implementation

The goal of Java is to make all implementations of Java compatible. Historically, Sun's trademark license for usage of the Java brand insists that all implementations be compatible. Sun sued in 1997, and, in 2001, won a settlement of US$20 million, as well as a court order enforcing the terms of the license from Sun. As a result, Microsoft no longer ships Java with Windows.


The Java programming language requires the presence of a software platform in order for compiled programs to be executed.


The Java language is a key pillar in Android, an open source mobile operating system. Although Android, built on the Linux kernel, is written largely in C, the Android SDK uses the Java language as the basis for Android applications. The bytecode language supported by the Android SDK is incompatible with Java bytecode and runs on its own virtual machine, optimized for low-memory devices such as smartphones and tablet computers.


The use of Java-related technology in Android led to a legal dispute between Oracle and Google. On May 7, 2012, a San Francisco jury found that if APIs could be copyrighted, then Google had infringed Oracle's copyrights by the use of Java in Android devices. This action was denied because it is not be copyrighted.


5. Comparison of Java and C++

The differences between the programming languages C++ and Java can be traced to their heritage, as they have different design goals.


C++ was designed for systems and applications programming as infrastructure programming, extending the procedural programming language C, which was designed for efficient execution. To C, C++ added support for object-oriented programming, exception handling, lifetime-based resource management, generic programming, template meta programming, and the C++ Standard Library which includes generic containers and algorithms and many other general purpose facilities.


Java is a general-purpose, concurrent, class-based, object-oriented programming language that is designed to minimize implementation dependencies. It relies on a Java virtual machine to be secure and highly portable. It is bundled with an extensive library designed to provide a full abstraction of the underlying platform. Java is a statically typed object-oriented language that uses a syntax similar to (but incompatible with) C++. It includes a documentation system called Javadoc.


The different goals in the development of C++ and Java resulted in different principles and design trade-offs between the languages.

54 views0 comments

Recent Posts

See All

Comments


bottom of page