1.short s = 1; s = s + 1; Is there a problem? What if it's solved?Short S = 1; s + = 1; Is there a problem? What if it's solved?2. Understanding:Short S=1;s=s+1;Nature is the compiler does not pass the hint loss accuracySo:Short S=1;S+=1;Why can it be compiled through that?There is one more question:Implicit type conversions can be auto-byte->short->int->long from small to large, that is, if you lose precision in turn, you must perform a display type conversionAnd S+=1 's meaning is different fr
path, but pass a OutputStream object?A: The reason is simple, the byte buffer stream only provides buffers, designed for efficiency. However, the actual read and write operation is also dependent on the basic flow object implementation.3. Bufferedoutputstream Write Data , code example:1 Packagecn.itcast_05;2 3 ImportJava.io.BufferedOutputStream;4 ImportJava.io.FileOutputStream;5 Importjava.io.IOException;6 7 Public classBufferedoutputstreamdemo {8 Public Static voidMain (string[] args)th
1. FileInputStream reading data One byte array at a time byte[]Use FileInputStream to read one byte array at a time:int read (byte[] b) return value : The return value is actually the number of bytes actually read.2. code example:1 PackageCom.himi.fileinputstream;2 3 ImportJava.io.FileInputStream;4 Importjava.io.IOException;5 6 7 8 /**9 * Ten * Use FileInputStream one byte array at a time: int read (byte[] b) One * Return value: The return value is actually the number of bytes actually read A
1. Requirements: Copy the D:\\english.mp4 to the current project directory Copy.mp4code example:1 Packagecom.himi.filecopy;2 3 ImportJava.io.FileInputStream;4 ImportJava.io.FileOutputStream;5 Importjava.io.IOException;6 7 /**8 * 9 * Requirements: Copy the D:\\english.mp4 to the current project directory Copy.mp4Ten * One */ A Public classCOPYMP4 { - - Public Static voidMain (string[] args)throwsIOException { the //Data Source -FileInputStream FIS =NewFileInputStream ("D:\\engl
is as follows:1 Packagecn.itcast_03;2 3 ImportJava.io.FileWriter;4 Importjava.io.IOException;5 ImportJava.io.PrintWriter;6 7 /*8 * 1: Any type of data can be manipulated. 9 * PRINT ()Ten * println () One * 2: Start auto Refresh A * PrintWriter pw = new PrintWriter (New FileWriter ("Pw2.txt"), true); - * or you should call the println () method to - * This time not only automatically refreshed , but also to achieve the data line-breaking . the * - * println () - * actually equivalent to :
Switch statements in Java:Here expression control expressions can only have data types of byte, short, char, int four integer types and enumeration types, and cannot be of type Boolean;Java7 (1.7) improved the Switch Branch statement;Java7 allows the control expression in the switch statement to be of type java.lang.String ( cannot be stringbuffer or StringBuilder)Switch (expression){Case Condition1:{statement (s);Break}Case Condition2:{statement (s);Break}Case Condition3:{statement (s);Break}..
(); atSystem.out.println ("sub.filed =" + Sub.field + -", Sub.getfield () =" + Sub.getfield () + -", Sub.getsuperfield () =" +Sub.getsuperfield ()); - } -}Output:sup.filed = 0, Sup.getfield () = 1sub.filed = 1, Sub.getfield () = 1, Sub.getsuperfield () = 0Analysis:The sub subclass actually contains two fields called field, whereas the default domain generated when referencing field in sub is not a super version of the Field field, so in order to get Super.field, you must explicitly indicate
long - * Float float - * Double double the * Char Character - * Boolean boolean - * - * Used for conversions between basic data types and strings. + */ - Public classIntegerdemo { + Public Static voidMain (string[] args) { A //No, the trouble is coming. at //Public static String tobinarystring (int i) -System.out.println (integer.tobinarystring (100)); - //Public static String tooctalstring (int i) -System.out.println (integer.tooctalstring (100)); -
specified source array, starting at the specified position and ending at the specified position in the destination array. - */ the Public classSystemdemo { - Public Static voidMain (string[] args) { - //Defining Arrays - int[] arr = {11, 22, 33, 44, 55 }; + int[] arr2 = {6, 7, 8, 9, 10 }; - + //please look at the meaning of this code ASystem.arraycopy (arr, 1, ARR2, 2, 2); at - System.out.println (arrays.tostring (arr)); - System.out.println (arrays.tos
responsible for accepting user input, and informs the second class object (Checkerboard object) The change of the chess piece layout, the Checkerboard object receives the change of the chess piece to be responsible to show this change on the screen, and uses the third kind of object (rule system) to decide the chess game.For a novice, want to put the object-oriented thinking in the development of the use of the easy, is not a simple thing, has been said object-oriented is a kind of thought, tha
1. First look at the case code as follows:1 Packagecn.itcast_07;2 3 /*4 * Stitch the array into a string5 */6 Public classStringBufferTest2 {7 Public Static voidMain (string[] args) {8 //define an array9 int[] arr = {44, 33, 55, 11, 22 };Ten One //Defining features A //Mode 1: Use String to stitch the way -String S1 =arraytostring (arr); -System.out.println ("S1:" +s1); the - //Way 2: Use StringBuffer to do the stitching way -String s2 =arrayToSt
1.Scanner Overview:JDK5 later used to get the user's keyboard input2.Scanner Method of Construction:Public Scanner (InputStream source)3. Case:1 Packagecn.itcast_01;2 3 /*4 * Scanner: Used to receive keyboard input data. 5 * 6 * In front of the time:7 * A: Guide Package8 * B: Create object9 * C: Call methodTen * One * There is a static field under the System class: A * public static final inputstream in; standard input stream, corresponding to keyboard input. - * - * InputStream is = syst
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.