Variables and data types

Java It's a strongly typed language . Data must have certain type before calculation

Basic data type ;   byte /short /int /long/( Accounting for 1-4 byte )

float(4 byte , precision 6-7 position )   double(8 byte , precision 15-16 position )

char Character ;  boolean Boolean type ( Judge / whether )

Reference data type ;  class   /interface  / Array

Character set    GB180309 The latest Chinese character set )

Unicode  International character set

Binary to decimal conversion

example ;  1010=0*2^0+  1*2^1+0*2^2+ 1*2^3

octal :015=5*8^0+1*8^1+0*8^3

Type of plastic surgery

A byte convention is 8 position         Range -128~127

One byte is byte type

Java The default writing shape in is int

Declare different types and add    L or F. Such as long 10=10L;


1.0 !=1    Floating point has precision

char type

Occupy 2 byte , Can represent characters , english , Chinese characters , Escape character . stay Unicode In the said .


First of all Use after assignment .

Variable names are made up of letters , Numbers _  $ And the first letter cannot be a number . You can't use system keywords .

It's usually named after hump , See the name and know the meaning .

Local variables can only be used in their scope :

Variables declared in a method can only be used in that method .

Member variables : Variables defined in the class ( It's defined in Outside of the method , Inside of class )

Member variables can be used in all non static methods in a class ;

If there is no initial value ,jvm Default assignment . Such as The default initial value of shaping is 0; Floating point is 0.0 The reference data type is null.


Initialization is assigned only once , Subsequent operations cannot be modified .

Naming conforms to variable naming rules , When a handful of letters are capitalized , See the words _ Separate .

Arithmetic operator

% Seeking remainder      / to be divisible by        a++ First calculate and then add 1    ++a First plus 1 Re operation .

&& And ( also ):    Short-circuit operation :  The previous operation has false , There's no arithmetic behind it ( If there is a change in the value behind it, it will not be calculated ), Direct output false

!    Take the opposite      !false=true;

An operator    int a=b<<2    Shift binary left 2 position ( Equivalent to times 4)

|| or ( One of them ) ;

java introduction -day02 More articles about

  1. Java Chapter one

    The day after tomorrow is the 11th holiday , Are you ready to go somewhere ? I'm a little free today , Let's talk about Java Well , Some, of course Java It's time to get started , There are many on the Internet , I'm just listing some of what I've learned , Thank you for following meow's blog for so long , And bring you something new ...

  2. [Java Entry notes ] Fundamentals of object-oriented programming ( Two ): Methods,

    What is the method ? brief introduction In the last one blog in , We know that methods are part of a class , An abstraction of the behavior of a class or object . In terms of grammar and function , Methods are similar to functions . however , Methods are different from traditional functions : stay ...

  3. The first 1 Chapter Java Entry experience

    The first 1 Chapter Java Entry experience Introduction and platform application Java yes sun The company developed , Now belongs to ORACLE company java Divided into sections : First, the most basic Java SE part , This part is Java Basic knowledge of , It mainly includes : ...

  4. Java Introduction ( 5、 ... and ): Sorting out the relationship between containers ( Next )——Map

    Be careful : When reading this article and related source code , Knowledge of data structure is required , Include : Hashtable . Linked list . Red and black trees . Map It's the key (key) Mapping to value (value) The object of . Different maps cannot contain the same key : Each key can be mapped to at most one value . The following is a common M ...

  5. Java introduction ( Two )—— Sure enough, those who break the watch will be punished ...

    For more than a month , The amount of reading immediately starts from 100+ Fall to 10-, Although I don't value it very much , After all, it's just my study notes , But some people see , Someone commented on , It's very comfortable for some people to agree and criticize , Especially those who have been deprived before , Miserable . A good writing ...

  6. Android It's new to me Android Studio&amp;JAVA introduction -- February can't be without writing

    Yes , I haven't given up blogging yet . Yes , I didn't give up either PHP Learning from . Yes , I'm going to start learning the most TM Fiery Android Developed . And you? 1.Android Studio One . survey Installation and configuration are not specific , Online one ...

  7. JAVA Notes JAVA introduction ( install +Dos Run under )

    JAVA Special introduction = =, After setting environment variables today, use dos When running, I found that “ Cannot find or load main class ”, I just checked some information and looked at it again JAVA The introductory part . Statement : For the time being, my notebook is Win10 System ,Windows other ...

  8. Java General contents of introductory course

    Java General contents of introductory course Ongoing update ... 1.Java Common sense 2.Java Frame comparison 3.Java technology roadmap 4.Java Coding standards 5.Java Environment variable configuration 6. enumeration 7. The operator 12. Timing task

  9. Java Introduction to the program summary

    Java Basic procedures for getting started , Although it's very simple , More practice, too , Here's a key summary 1.HelloWorld Let's not talk about this 2. Constant and variable parts Basic data type usage public class Javashujuleixin ...

Random recommendation

  1. Knockout.js With your hand (6)

    Reflect the change of object property in real time In the previous blog, we used the following code to add user object , namely push Method : $("#btnAddUser").click(function () { vm.use ...

  2. 3、 ... and 、Spring—— The data access

    1.Spring Yes DAO Support for Spring Support most common data persistence technologies ,Spring Defines a set of goals for DAO The anomaly system of the layer , Exception converters are not provided by various supported persistence technologies . such , We're designing DAO Interface ...

  3. HTML Labels and forms

    1. open DREAMWEAVER, newly build HTML, Here's the picture : 2.body Properties of : bgcolor Page background color background     Background wallpaper . picture text   Text color topmargin    above ...

  4. splinter python Browser automation , Simulate browser behavior

    Splinter It can simulate the behavior of browser very well ,Splinter Provides a wealth of API, You can get the information of the page and judge the result of the current behavior   Recently, I'm studying the problem of automatic login of website , Involves the need to achieve browser automation , Online ...

  5. Section DP introduction

    First of all, we need to know how interval is used dp To do the , Let's take a look at the template . ; i <= n; i++){// Enumerate the numbers in an interval ; j <= The largest one that can be enumerated pos; j++){ ;// At present, we can ...

  6. use css3 Filtering makes the mask effect

    <!DOCTYPE html><html ng-app="myApp" ng-controller="myController">< ...

  7. Xamarin.Android Delay jump in Method 1 : Use Handler().PostDelayed Delayed start new Handler ...

  8. dubbo Source code —service reference

    service reference After writing the service ,dubbo Will serve export get out , This is the time to write consumer To call this service .dubbo As a rpc frame , Users use remote services and local services ...

  9. Mybatis Escape character

    Mybatis Of sql You need to use '>' perhaps '<' when , Can't be used directly . < < Less than no. > > More than no. & & and &apos; ' Single quotation marks ...

  10. elasticsearch Launch common errors

    The environment where the problem occurs ,OS edition :CentOS-7-x86_64-Minimal-1708:ES edition :elasticsearch-6.2.2. 1.max file descriptors [4096] for ...