Java Learning Lesson One (first knowledge of Java)

Source: Internet
Author: User

PS: Back ACM Training Team, oneself also crazy play two days, the day after tomorrow, on the formal sophomore, the win their hearts good study         

Java Overview


First, let's review basic knowledge:

1. Software development

2. Human-Computer Interaction

3. Frequently used DOS commands

First, software development

What is software?

Software is a set of computer data and instructions that are organized in a specific order (instructions: How to process data)

Common software is: System software (DOS, WIndows, Linux), application software (QQ, 360, Thunderbolt)

So, software development means making software, organizing a series of data and collections.

Second, human-computer interaction

Software enables people and computers to interact better

Interactive mode:

1, graphical interface (graphical User INTERFAC, referred to as GUI), the popular saying is that I want to open QQ, sure to double-click the QQ icon, I want to delete a directory, right-click this figure punctuation Delete, these are graphical interface operation

2, command line (graphical lines INTERFAC, short CLI), the earliest operating system DOS, there is no graphical interface, what you want to do, you have to give a command to the computer, of course, it needs a console , enter a specific instruction, so you must log some commands


Java language Overview

Java was launched by Sun in 1995, has been around for nearly 20 years, Java is based on the rise of the Internet, and more and more fire. Java has become the preferred language for Web applications.

Java features: Completely object-oriented, secure, platform-independent.


Three architecture of the Java language

1.J2EE (Enterprise Edition) is primarily an application in the development of enterprise environments.

2.J2SE (Standard Edition) is the foundation of the other two architectures, mainly to develop some major desktop applications, that is, we do some desktop small software on the system

3.j2me (small edition) mainly develops electronic products and embedded devices, such as mobile games (of course Android The operating system already provides a set of development tools, which means you can choose the direction of Android Development, iOS software development, software is the same, only the operating system is not the same )

JAVA5.0 renamed Java EE, javase, javame


Java is Oracle after the company acquires, connect with Java Oracle, you can seamlessly connect without having to install some drivers

Seamlessly connect and develop fully compatible products based on the full mastery of the system's underlying protocols and interface specifications. For example, Windouws95 and 98,XP are not, XP is the client


To learn Java,java will be a good fire.


The cross-platform features of the Java language:

The so-called platform, refers to the operating system platform, but the platform is not an operating system.

Windows system before the main application of C to write, late to join C + +, different vendors launched a different system, so on its system can execute the software written by C + +, but other languages can not, of course, Java is not. Because the operating system is different, the parsing method is different.

The Java language can be implemented across platforms, software written in Java can now be executed on Windows, and can be executed on Linux


Because Java has a JVM (Java Virtual machine), the JVM enables Java to implement cross-platform features, i.e. Java has good portability.

So just install the JVM on one system, and Java will be able to execute on whatever system.


JDK and JRE

Understand Java's JDK (Java Development Kit), JRE (Java Execution Environment)

JRE:JVM + Class Library

JDK:JRE + Java Development tools

In accordance with the requirements, assuming that only the Java program is simply executed, only need to install the JRE, assuming that the development of Java programs, then install the JDK.

Java programs developed with the JDK are handed to the JRE for execution.

Install JDK with environment configuration, Connection:http://jingyan.baidu.com/article/6dad5075d1dc40a123e36ea3.html


Classic Hello Word


Each Java program must have a main method, public static void main (string[] args): Java is executed in order not from top to bottom, but rather first found "public static void Main (string[ ] args) ", which is like the entrance to a program execution


public class Main//defines a main class where public makes its priority rise and can not write {public    static void Main (string[] args)//entry of the program    {        System.out.println ("Hello wprld");        Print Plus ln causes the cursor to take its own initiative to the next line    }}


Simple A+b


Import Java.util.scanner;public class main{public    static void Main (string[] args)    {        Scanner cin = new Scanne R (system.in);        int a, B;        A = Cin.nextint ();        b = Cin.nextint ();        System.out.println (a+b);    }}

Ps:java study, mainly rely on more knocking, more practice, not afraid of the wrong


Then a Java interview question: Ask Line10 and Line11 what's the Difference

Import Java.util.scanner;public class Main {public static void Main (string[] args) {Scanner cin = new  Scanner (System. In), short a = 4;a + = 2;    A = a + 2; System.out.println (a); Cin.close ();    }}

4 compiler, default is decimal, accounting for 4 bytes, A is a short type of two bytes, the assignment, first infer whether 3 satisfies the range of short, meet, discard 3 first two bytes

+ = is an assignment operator,

Line10: (correct) to know why Line10 is correct, you need to know that short a = 4 why, because at the time of assignment, the computer will infer that the value assigned to a is satisfied with the short, so + = is equivalent to a one-step operation, only the assignment is not the value to the right, is a itself and = right value and , it is inferred at the bottom and whether it satisfies the short

LINE11, (error), assuming that the initial a is the maximum value of short, then the +4 is super short range.

Workaround: A = (short) (a+4);

Same as Byte.

+ =, which is an extended assignment operator, actually implies a forced type conversion

Remember one point:

A + = 4;

Not equal to A = a + 4;

Instead, it is equivalent to a = (the data type of a) (A + 4);

Java Learning Lesson One (first knowledge of Java)

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.