Java Fundamentals (v)

Source: Internet
Author: User
Tags type null

Here are some of the lessons I summarized in the previous lesson and the code is most of the teacher's notes personally think is very good, but also a more classic content, sincere hope that these for those who want to learn some help!

Because the code is sub-module upload is very inconvenient. Also more, speak of is more clear! If you need to be able to leave your email in the comments I see will be sent to you for free! Thank you for this platform let us all progress together!! Remember that the programmer is selfless!!!

Also very welcome to my blog to watch the blog address: http://www.cnblogs.com/duscl/

/*1: Method (Mastering) (1) Method: A block of code that completes a particular function.    Note: In many languages there is a definition of a function, whereas in Java, a function is called a method. (2) Format: Modifier Returns a value of type method name (argument type parameter name 1, parameter type argument Name 2 ...)            {method body statement;        return value; } modifier: Use public static now.        Further details on other modifiers return value types: is the data type method name of the functional result: it is a name that makes it easy for us to call the method. Parameter type: is the parameter's data type parameter name: is the variable parameter classification: argument: The actual participation in the operation of the data parameter: method defined, to receive the actual parameters of the variable method body statement: Is the completion of the function of the generation    Code block Return: End method return value: Is the result of the function, returned by the return to the caller. (3) Two clear: Return value type: The data type parameter list of the result: number of parameters and corresponding data type (4) method call A: Method with definite return value A: Call alone, no meaning B: The output call is not good because I may need to do further operations without results.            But I used the lecture in general.        C: Assignment invocation, recommended scheme b:void type modification method A: Call alone (5) Case: A: Sum scheme B: Get the larger of two numbers C: compare two data is the same D: Get the maximum of three numbers E: The star of the output m row n column F: output nn multiplication table (6) Method Note A: method does not call do not execute B: method is a peer relationship and cannot be nested when defining C: Method definition    The parameter is used, separated by the D: Method at the time of invocation, do not pass the data type E: If the method has an explicit return value type, it must have a return statement returned. (7) method overloading in the same class, the method name is the same, and the parameter list is different.Is independent of the return value.            Parameter list is different: The number of parameters is different.    The corresponding data type of the parameter is different.        (8) Method overload case comparison of multiple methods with the same name for different types.    2: Array (mastering) (1) Array: A container that stores multiple elements of the same data type.             (2) Features: Each element has a number, starting from 0, the maximum number is the length-1.        Number of professional names: Index (3) define format A: data type [] array name;                B: Data type array name [];        Recommendation is a way, B method forget it.        But to be able to read (4) Initialization of an array A: Dynamic initialization gives only the length, the system gives the default value example: int[] arr = new INT[3];            B: Static initialization of the given value, the system determines the length example: int[] arr = new int[]{1,2,3};    Simplified version: int[] arr = {£ º}; (5)                Java memory allocation A: Stack storage local variable B: Heap store all new C: Method Area (Object-oriented section details) D: Local method Area (System dependent) E: Register (CPU usage)            Note: A: A variable that is defined by a local variable in a method definition or a method declaration.                B: Stack memory and heap memory difference stack: The data is used, it disappears. Heap: Every new thing that comes out has an address. Each variable has a default value of Byte,short,int,long 0 float,  Double 0.0 char ' \u0000 ' Boolean false                      Reference type NULL when the data is used, it is reclaimed when the garbage collector is idle.                (6) Array memory Figure A: An array of B: Two arrays C: three arrays (two stack variables pointing to the same heap memory) (7) Array of common operations A: Traverse Mode 1:                        public static void PrintArray (int[] arr) {for (int x=0; x<arr.length; x + +) {                    System.out.println (Arr[x]);                    }} mode 2:public static void PrintArray (int[] arr) {                    System.out.print ("["); for (int x=0; x<arr.length; x + +) {if (x = = arr.length-1) {System.out.                        println (arr[x]+ "]");                        }else {System.out.println (arr[x]+ ",");                    }}} B: Maximum value: public static int Getmax (int[] arr) {                                        int max = arr[0]; for (int X=1; x<arr.length;                        X + +) {if (arr[x] > max) {max = arr[x];                }} return max; Minimum value: public static int getmin (int[] arr) {int min = arr[0]                                        ;                         for (int x=1; x<arr.length; x + +) {if (Arr[x] < min) {min = arr[x];                }} return min; } C: Reverse mode 1:public static void reverse (int[] arr) {for (int x=0; x< ARR.LENGTH/2;                        X + +) {int temp = arr[x];                        ARR[X] = Arr[arr.length-1-x];                    Arr[arr.length-1-x] = temp;                }} Mode 2:public static void reverse (int[] arr) {for (int start=0,end=arr.length-1; start<=end; start++,end--)                        {int temp = Arr[start];                        Arr[start] = Arr[end];                    Arr[end] = temp;                    }} D: Check table public static String getString (string[] Strarray,int index) {                return Strarray[index]; } E: Basic Find method 1:public static int getindex (int[] arr,int value) {for (in T x=0; x<arr.length;                        X + +) {if (arr[x] = = value) {return x;                }} return-1; } mode 2:public static int getindex (int[] arr,int value) {int                                    index =-1;       for (int x=0; x<arr.length; x + +) {                 if (arr[x] = = value) {index = x;                        Break                }} return index; }*\

Java Fundamentals (v)

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.