The first day of Java learning

Source: Internet
Author: User

installation and configuration of the JDK:

Download:

Installation: Fool type (note: Do not install in C- Plate)

Configuration:

1, Java_home

2, Classpath

3, Path

Verify:

1, Javac

2, Java-version

Installing Myeclipse/eclipse

Open it:

Create a project

leftmost blank - right --new Java project-project name-(note)-finish

Note : ( naming conventions for Java identifiers)

1, composed of letters, numbers, underscores (_), dollar signs ($), numbers cannot begin

2, cannot be a keyword or reserved word in Java (const,goto)

3, Hump-type naming, case-sensitive, no length limit, see the name of the idea

int age = 18;

data type variable name assign value number variable value

data types in Java:

Basic data type: Four classes of eight

shaping:byte (1), short (2), int (4), Long (8)

Float :float (4), double (8)

Character:Char

Boolean:boolean (True/false)

Reference data type:

Rotation: Data type range from small to large

Strong turn: Data types range from large to small

Comments:

Single-line comment://

Multiline Comment:/* */

Document Comment:/** */

Process Control statement:If else switch case, for, while,do while

Statement structure, expression

Cycle:

When to use loops: a lot of repetitive business logic

The difference between the while and do while:

installation and configuration of the JDK:

Download:

Installation: Fool type (note: Do not install in C- Plate)

Configuration:

1, Java_home

2, Classpath

3, Path

Verify:

1, Javac

2, Java-version

Installing Myeclipse/eclipse

Open it:

Create a project

leftmost blank - right --new Java project-project name-(note)-finish

Note : ( naming conventions for Java identifiers)

1, composed of letters, numbers, underscores (_), dollar signs ($), numbers cannot begin

2, cannot be a keyword or reserved word in Java (const,goto)

3, Hump-type naming, case-sensitive, no length limit, see the name of the idea

int age = 18;

data type variable name assign value number variable value

data types in Java:

Basic data type: Four classes of eight

shaping:byte (1), short (2), int (4), Long (8)

Float :float (4), double (8)

Character:Char

Boolean:boolean (True/false)

Reference data type:

Rotation: Data type range from small to large

Strong turn: Data types range from large to small

Comments:

Single-line comment://

Multiline Comment:/* */

Document Comment:/** */

Process Control statement:If else switch case, for, while,do while

Statement structure, expression

Cycle:

When to use loops: a lot of repetitive business logic

The difference between the while and do while:

Import Java.util.Scanner;

public class Demo {
public static void Main (string[] args) {
An expression
/* Test instructions: Temperature above 35 degrees, go swimming. Otherwise, sleep at home.
Ideas
* 1, create the temperature variable int tem = 28;
* 2, compare temperature
* tem>35 Result: Go swimming
* tem<=35 Result: sleeping
*
Practice
* If my salary is below 3000, buy Xiaomi phone
* Under 4000, buy Nokia
* Under 5000, HTC
* Under 6000, apple
*
* */
int salary = 3800;
if (salary<3000) {
System.out.println ("buy millet");
}else if (salary<4000) {
System.out.println ("buy Nokia");
}else if (salary<5000) {
System.out.println ("HTC");
}else if (salary<6000) {
System.out.println ("buy apples");
//}

Switch case

Scanner AA = new Scanner (system.in);
System.out.println ("Please enter data");
int day = Aa.nextint ();
Switch (day) {
Case 1:
System.out.println ("Monday");
Break
Case 2:
System.out.println ("Tuesday");
Break
Case 3:
System.out.println ("Wednesday");
Break
Case 4:
System.out.println ("Thursday");
Break
Case 5:
System.out.println ("Friday");
Break
Case 6:
System.out.println ("Saturday");
Break
Case 7:
System.out.println ("Sunday");
Break
Default
System.out.println ("Sorry, you have to go back to Mars, the Earth is only 7 days a week");
//}
/**
* Exam, 90--100 points, excellent, 80--89, good, 70--79, General, 60--69, pass, 60 below, fail
* */

Scanner input = new Scanner (system.in);
System.out.println ("Please enter your score:");
int score = Input.nextint ();
if (score<0 | | score>100) {
SYSTEM.OUT.PRINTLN ("incorrect input");
}else{
Switch (SCORE/10) {
Case 0:
Case 1:
Case 2:
Case 3:
Case 4:
Case 5:
SYSTEM.OUT.PRINTLN ("fail");
Break
Case 6:
SYSTEM.OUT.PRINTLN ("Pass");
Break
Case 7:
System.out.println ("General");
Break
Case 8:
System.out.println ("good");
Break
Case 9:
Case 10:
System.out.println ("excellent");
//}
//}
124
for (int i = 0; i < i++) {
3
System.out.println ("First" + (i+1) + "Times: Little Red, I Love You");
//}


int a = 0;
while (a>5000) {
System.out.println ("+a+" "Times: Little Red, I Love You");
a++;
//}

int a = 0;
do{
System.out.println ("First" + (a+1) + "Times: Little Red, I Love You");
a++;
}while (a>5000);


/*
* Ask for an even and, even number of 1--100 between
* */
int sum = 0;
int count=0;
for (int i = 1; i <=; i++) {
if (i% 2 = = 0) {
Sum= Sum+i;
count++;
//}
//}
System.out.println ("Between the 1--100 and is:" +sum);
System.out.println ("An even number is:" +count);

What's the case with the IF else?

Scanner sc = new Scanner (system.in);
System.out.println ("Please enter data:");
String name = Sc.next ();
char c = ' R ';
Long B = 3;
Switch (b) {
Case 1:
SYSTEM.OUT.PRINTLN ("You have entered true");
Break
Case 3:
SYSTEM.OUT.PRINTLN ("You have entered false");
Default
Break
//}

for (int i = 1; I <= 9; i++) {
for (int j = 1; J <= I; j + +) {
System.out.print (j+ "*" +i+ "=" +i*j+ "");
//}
System.out.println ();
//}

for (int i = 1; I <= 9; i++) {//Line
for (int j = 1; J <= I; j + +) {//Column
System.out.print (j+ "*" +i+ "=" +i*j+ "");
//}
System.out.println ();
//}

/**
* Hundred dollars to buy hundreds of chickens, Rooster: 5 Yuan A, hen: 3 Yuan A, chicken: 1 Yuan 3 only, requirements, cocks, hens, chickens must have, Q: can buy a few cocks, a few hens, a few chickens?
* */








}
}

The first day of Java learning

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.