Basic Java Knowledge

Source: Internet
Author: User

< a > The difference between a member variable and a local variable

1> scope different member variables can use local variables in the entire class can only be used in the method 2> member variable system default initial value is 0 local variable without default initial value must be initialized 3> different methods can have local variables with the same name Local variables with the same name are not allowed in the same method 4> local variables with the names of member variables.

< two > operator

logical Operators

Ternary operatorsString str = (8>5)? "8 is greater than 5": "8 not greater than 5"; System.out.println (str);
Precedence of Operators

< three >Java Constants

A constant is a special variable whose value is set and cannot be changed during program Operation .
Syntax Final constant name = value (constant name is generally capitalized)final String SEX = "male";Final double PI = 3.14

< four > porting of Eclipse programs
1> in the Package Explorer, select the migration to Project 2> on the project, right-click on the property 3> copy and open the project site 4> copy the project to the folder 5> when you need to migratePackage Explorer Right-click Import to select a generic file already exists and find the folder where the item is located

< Five >java JDK configuration

1> download JDK1.8 and install 2> Locate the post-installation JDK and JRE file location 3> Configure environment variables to open computer properties -Advanced system Settings -Environment Variables-> New system Variable java_home -set the variable name toC:\Program files\java\jdk1.8.0_91 (2nd step JDK location) -System variables look for path variables and edit -Enter the value of the variable last;%java_home%\bin;%java_home%\jre\bin;(be careful to use; separate)new system variable classpath variable value.; %java_home%\lib;%java_home%\lib\tools.jar (Note that there is a point in the front)
system Variable Configuration complete4> Check if the configuration is correctRun the cmd input java-version
If the version information is displayed, the installation and configuration are successful.

< six > static variables and static methods
Static Variablesin Java, static variables are modified toit belongs to the whole class, not an object,can be accessed directly through the class name, or through an object.when the system first uses the class, it allocates space in memory until the class is unloaded before the resource is recycled .
Static Methodsstatic method in Java is modified by staticcan be accessed directly by the class name or by using an object.Static members or methods can be accessed directly in a static method, but non-static members cannot be accessed directlyor Method, you can access non-static members by creating objectsor Method(normal method can directly access the same non-static membersor Method)
< seven >java access modifiers
Private        can only be accessed in this classdefault           can be accessed in this class or in the same packageprotected     can be accessed in this class, in subclasses, or in the same package Public           can be accessed at any location
< eight >final keywords
Final has the ultimate meaningthe class cannot be inherited when the final decorated classThe method cannot be overridden when the final decoration methodThe final modifier property can be assigned only once at the time of declaration or once in a constructor method, and the system will not automatically assign a value


From for notes (Wiz)

Basic Java Knowledge

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.