Java Basics Summary

Source: Internet
Author: User
Tags naming convention switch loop

Package Zhangkai;

public class Zongjie {
/*
* Package Zongjie;
/*
* Java Basics Summary
*/
/* Development of computer language:
* Machine language, assembly language, advanced languages (compile, Debug)
*
* Programming Steps:
* Analyze problems, establish data types and algorithms, compile programs, debug problems
*
* Common errors:
* Syntax error, logic error, development error, run error
*
*
*
* Identifier rules:
* Identifiers cannot be keywords or true, false, NULL
* Identifiers can contain letters, numbers 0-9, underscores (_), or dollar signs ($)
* The first character of the identifier must be a letter, an underscore (_), or a dollar sign ($)
* Identifiers are case-sensitive, with no specified length
* (soft: First letter lowercase (except for class one))
* (Hump method: Except for the first word, the first letter of other words capitalized)
*
*
* * * * type conversion:
* * Implicit conversions: low-to-Advanced (auto-convert) * Cast: advanced to Low Level
* For example: Byte i=0; For example: int i=99;
* int a=i; BYTE B=bytei;
* Long b=i; Char f=i;
* Float c=b; Double d=f;
* Double d=c; f= (float) D;
* Short j=i;
*
* * * * Basic data type automatic operation rules:
* * All byte type, short type, char type, computer result is int type
* Byte I=1; Short j=2; Char m=3;
* int sum=i+j+m;
* * If one of the operands is long, the computer result is a long type
* Byte I=1; Short j=2; Char m=3; Long n=4;
* Long sum=i+j+m+n;
* * If one of the operands is float type, the computer result is float type
* Byte I=1; Short j=2; Char m=3;float n=4;
* Float sum=i+j+m+n;
* * If one of the operands is of type double, the computer result is double type
* Byte I=1; Short j=2; Char m=3;float n=4;double c=6;
* Double sum=i+j+m+n+c;
*
* * * * basic syntax:
* * * SELECT statement:
* *IF statement:
* IF (i==0 (Boolean expression)) {
* Statement
* }
*
* *if/else statement:
* if (Boolean expression) {
*
*}else{
* Statement
* }
*
* *switch statement:
* Scanner in=new Scanner (system.in);
* String Shuru (input something) =in.next ();
* Char chr (custom) = Xuanze (variable). ToCharArray () [0]; Convert a string to a character
* Switch (CHR) {
* case ' a ':
* Statement
* BREAK; Not every case has to be used with Break,break for any loop structure, so that this level of the loop terminates
*
* case ' B ':
* Statement
* BREAK; Jump out of the switch loop when you encounter a break
*//continue is skipping this cycle. To the Next loop
*
*
* case ' C ':
*system.exit (-1); Exit the entire loop
*break;
*
*
* Defauit://Input selection is not in front, need to re-select
* BREAK;
*
* }
*
*
* * * * Loop statement:
* *for Loop://(array traversal)
*
* FOR (int i=0 (initialization); I<50 (boolean expression); i++ (update)) {
* Statement
* }
*
* Maximum difference between **while and for loops:
* While is used for unknown number of cycles, and ends when a condition is not satisfied
* For loop is to know the number of loops
*
* *while Cycle:
*
*//(when a switch is nested in while, the switch is exited when Baeak is encountered, but the while contains a switch and is entered in the loop)
*
* while (Boolean expression) {
* }
*//while (True) {
*switch{
*case ' A ':
*while (True) {
* Statement
*break; This is jumping out of switch, but still in the while loop
*continue; This is skipping this step and looping through the while in the switch
*}
*}
* }
*
* *do/while Loop://(at least once)
* For example: int y=10;
* do{
* SYSTEM.OUT.PRINTLN (y);
* Y+=10;
*}while (Y&LT;=100)
*
*//The result of the final output is a calculation and a result in 100,do, while the condition of performing do
*
* Recursive
* For a finite loop, but the last run requires a previous result
* Recursion is also a kind of loop that allows a method to call itself
* Saymylove ();
* public static void Saymylove () {
* SYSTEM.OUT.PRINTLN ("I Love You")
* }
*
* * * * array:
* * Array of expressions:
* * Data type +[]+ variable name ={};
* int [] sum={1,2,3,4,5};
*
* * Define new array, give length only
* int [] sum=new int[5];
*
* The subscript of the array is starting from 0
*
* * Array Traversal:
* for (int i=0;i<sum.length;i++) {
* SYSTEM.OUT.PRINTLN (sum[i]);
*}3
* * Convert uppercase to lowercase:
* String **=**.tolowercase ();
* * Convert lowercase to uppercase:
* String **=**.touppercase ();
* * Converts a string to a character:
* Char **=**.tochararray () [0];
* * * Data typical case
* * Summation: 1+2+3+4+5+6
* int y=0; Define a new value, y equals 0
* FOE (int i=0;i<6;i++) {
* Y=y+x[i]; Each time y is by the front and y plus this time x[i]
* }
* SYSTEM.OUT.PRINTLN (y);
*
public class Javaoo1129_1 {
/*class is a keyword that indicates a class
* Public is an access modifier that represents where you can access the class using this
* Details: 1. If a class is public, the class name must be consistent with the Java file name
* 2. A class file, the name of the class file is only associated with the category name
Property---Variable property is private and provides a get/set method that conforms to the naming convention
is automatically initialized with a base data of 0
(Char and Boolean values are 0, but the method is different, one is blank, and the other is false)
Reference type is NULL
public String name;
public int hight;
public int wig;
Construction Method---Effect: Object generation
Must have a public non-parametric structure (to write the parameter structure, you must first write the method of the non-parametric construction)
Finally, the functional method of writing
Behavior
public void shuiping () {
System.out.println ("Hello");
}
*/
/*
* Package Com.javaOO.bean;

Char type, uppercase to lowercase, lowercase to uppercase. Others do not turn, print out
public class Class {
public static void Main (string[] args) {

Char[] Array = {' H ', ' e ', ' l ', ' l ', ' O ', '! '};
ChangeCase (array);
ChangeCase (' W ', ' R ', ' B ', ' r ');
}

When an array is a formal parameter, there are two ways of declaring it,
1. Traditional mode [], the caller can only pass array objects
The new way after 2.jdk1.5 ... The caller can either pass an array object or pass an element of any number of groups directly
public static void ChangeCase (char [] array) {
public static void ChangeCase (char ... array) {
Only used when the array is a parameter ...
for (int i = 0; i < Array.Length; i++) {
if (Array[i] >= ' A ' && array[i] <= ' Z ') {
array[i]=array[i]+32;
Array[i] + = 32; Uppercase to lowercase plus 32
} else if (Array[i] > ' A ' && array[i] <= ' z ') {
Array[i] = (char) (Array[i]-32);
}
}

}
}

*/
}

Java Basics Summary

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.