Basic Java Tutorial: Object-Oriented Programming

Source: Internet
Author: User
Tags wrapper

Java Essentials Tutorial: Object-Oriented Programming Java language Overview Java language features

1. Java is a purely object-oriented language that can directly reflect real-life objects. In short, everything is object!

2. platform agnostic . Java is an interpreted language, and the compiler will turn Java code into "" "Intermediate Code" and then interpret execution on the JVM.

The 3.Java provides a number of built-in class libraries that simplify developer program design and shorten project development time.

The 4.Java language provides support for Web applications .

The 5.Java language provides better security and robustness .

To enhance the security of the program, the Java language provides a security mechanism for preventing malicious code attacks (array boundary detection and byte code validation, etc.)

Java's strong-type mechanism, garbage collection mechanism, exception handling, and security detection mechanisms make programs written in the Java language robust.

Java Development Kit

  

Class Loader

java classloader ( English:java Classloader) is part of the Java Runtime Environment (Java Runtime Environment) and is responsible for Dynamically load Java classes into the memory space of a Java virtual machine. The class is typically loaded on demand, which is the first time the class is used. Because of the ClassLoader, the Java Runtime system does not need to know the file and file system . When learning the ClassLoader, it is important to master the concept of Java delegation.

Each Java class must be loaded into memory by a class loader. Java programs can take advantage of external libraries (software libraries written by other authors).

There are 3 default class loaders in the JVM:

    1. Boot (Bootstrap) class loader. Written by native code (such as C), not inherited from java.lang.ClassLoader . Responsible for loading the core Java library, stored in the <JAVA_HOME>/jre/lib directory.
    2. Extension (Extensions) class loader. The extension library that is used to <JAVA_HOME>/jre/lib/ext load Java in, or in the java.ext.dirs directory indicated in. The implementation of the Java virtual machine provides an extension library directory. The ClassLoader finds and loads the Java class in this directory. This class is sun.misc.Launcher$ExtClassLoader implemented by.
    3. The Apps class loader (also known as the System ClassLoader). The Java class is loaded according to the Java application's classpath ( java.class.path or CLASSPATH environment variable). In general, Java-applied classes are loaded by it. It can be obtained by Classloader.getsystemclassloader (). This class is sun.misc.Launcher$AppClassLoader implemented by.

Each class loader has a parent loader (loader).

Garbage collection mechanism

The Java language provides a garbage collector to automatically detect the scope of objects, implement automatic, and free up storage space that is no longer being used.

The garbage collector accomplishes three main tasks: allocating memory , ensuring that the referenced object's memory is not being reclaimed incorrectly , and reclaiming the memory space of objects that are no longer referenced .

When an object reference is assigned to NULL, and the object has no references, the GC marks the object as garbage and reclaims the garbage for a later indeterminate period . The so-called uncertainty refers to what time recycling, the programmer can not control

Basic data types and their wrapper classes

Java not only supports the following 8 basic data types, but also provides the corresponding wrapper classes for these 8 basic data types, and through these wrapper classes, we can treat the above basic data types as class objects in Java. It is worth noting that the basic data types can be manipulated directly in a Java program, but in some cases they need to be treated as objects, which need to be handled with the wrapper classes corresponding to the basic data types in the Java API.

For example, the Boolean wrapper class provides a summary of the methods:

 boolean booleanValue()
Returns the value of this Boolean object as a basic Boolean value.
 int compareTo(Boolean b)
Compares this Boolean instance to another instance.
 boolean equals(Object obj)
Returned when and only if the parameter is not null , but is an object that represents the same value as this object Boolean boolean true .
static boolean getBoolean(String name)
Returned if and only if the system attribute named with the parameter exists and is equal to the "true" string true .
 int hashCode()
Returns the hash code for the Boolean object.
static boolean parseBoolean(String s)
Resolves a string parameter to a Boolean value.
 String toString()
Returns a String object that represents the Boolean value.
static String toString(boolean b)
Returns a String object that represents the specified Boolean value.
static Boolean valueOf(boolean b)
Returns a Boolean instance that represents the specified boolean value.
static Boolean valueOf(String s)

Basic Java Tutorial: Object-Oriented Programming

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.