Java starts from scratch and the basics of learning notes (1)

Source: Internet
Author: User

Java technology system has three directions: j2ee (for enterprise-level development), j2se (for individuals), and j2-java (for mobile development, it is mainly reflected in the strict Type Definition of the variable type. If it is an int, a variable of the int type must be defined to receive int I = 1; boolean flag = true weak type language: the variable type is not strictly defined. It defines a variable that can receive all types of data. For example, javascript scripting is a weak type language. var I = false; advanced programming language type: compile a class file in the interpreted Java language. When the class file is completed from the creation stage to the compilation, and there is no error, the file is in a compilation process, the file is a binary bytecode file *. class, and then our JVM (Java Virtual Machine) is loaded through the class Loader classLoader *. the class file, which is interpreted by the JVM as a computer, and then displayed that Java is both a compilation language and a solution. Release language. Run jdk1.6.exe and install jdk. After installation is complete, two files are generated: jdk1.6.0 and jre1.6.0. After installation is complete, you need to set the Path for the environment variables: classPath: Specifies the path for storing java class files. "." Indicates the directory in which the source code file is located, and the compiled file is stored in the directory. Create a HelloWorld. java file public class HelloWorld {public static void main (String args []) {System. out. println ("java_lu") ;}} notes when writing the source code above: * The class name must be exactly the same as the file name. * one class has only one main method. When a class is loaded by JVM, the main method is called by default, in addition, the main method must be modified with the static keyword. You do not need to create an object when calling the main method. * The parameter passed by the main method is the S capital of a String array String word * the output statement System S capital output content is "" caused by the parameters passed in the Main method: pass a String array in the main method. The array name is specified by sun as args, which can be changed in general. When we output the array parameters, output public class HelloWorld2 {public static void main (String args []) according to the array output mode {// cyclically output the String array // System. out. println (args [0]); // System. out. println (args [1]); for (int I = 0; I <args. length; I ++) {System. out. after writing println (args [I]) ;}}, compile the source code, and then compile the binary The bytecode file is interpreted. parameters are passed during interpretation. When multiple parameters are passed, the Main method is separated by spaces between parameters. The Main method can also throw an exception or directly throw an exception in the method. Object-Oriented Programming (I) EveryThing is object (EveryThing is an object) class and object class are descriptions of a class of things, an abstract conceptual definition object is an entity that actually exists in this class of things. Syntax formats of classes including attributes, methods, constructors, and (classes): class name {attribute; method; constructor ;} [<modifiers>] class <class_name> {[<attribute_declarations>] [<constructor_declarations>] [<method_declarations>]} a student entity is a class, public class Student {String stunum1; // Student ID int age = 18; // age String stuname; // name String stusex; // gender // One method outputs all student information public void show () {System. out. println (stuname + stunum1 + age + stusex);} belongs Definition: Declaration of Object Description attributes: syntax format: [<modifiers>] type attribute name = [default value]; Modifiers (access modifier) has four: public (public), private (private), protected (protected Type), default (default) Type (Type): String, int (integer) boolean, char, float, double, byte, short, and long) q1: which is not one of the eight basic data types? Q2: Can a char variable store one Chinese character? Yes. A Chinese Character occupies two bytes, and a char variable also represents the declaration of the Two-byte method: [<modifiers>] <return_type> <name> ([<argu_list>]) {[<statements>]} return_type return type: 8 Basic Data Types String Void collection object Public int show () {} Public String show1 () {} Public void show2 () {} Public List show3 () {} Public Student show4 () {} Public void show () {} Public void show1 (int I) {} Public void show2 (int I, string name) {} Public void show3 (int I, String name, boolean flag) {} Public void show4 (List list, String [] strs, Student st ){}

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.