C② initialization behavior that conforms to the expected logic(2) Shallow copy and deep copy① the physical state of the object after the copy is the same → the copy constructor provided by the compiler is only shallow copy② the logical state of the object after copyingInitialization of the "Programming Experiment" object(3) When a deep copy is requiredA member o
JAVA learning lesson 28th (Common Object API)-String class, apistring
Multithreading has come to an end. You need to back up common object APIs !!!
Developed in the future, the most common object is text, or string.
String type
A string is a special object.
The string cannot
, create object two objects in heap memory//one is S1 a "ABC" System.out.println (s = = S1);//false, the address value of the comparison is not the same System.out.println (S.equals (S1));//true/* equals in the String class has a copy of equals in object that establishes the string class * its own judgment string object is the same * that is, compare string conte
An assignment compatibility rule is a case in which an object of a derived class can be used as an object of the base class in a public-derived case.The contract class derived is derived from the class base public, which refers to the following 3 scenarios:(1) A derived object can be assigned to an object of the base c
,//stream can manipulate the file object Pro.store (FW, "after Change");}
Iv. Practice
Get the number of uses of an application, more than 3 times, give information about the number of times the usage has been registered, and do not run the program again
Analysis:
This requirement requires a counter, each time the program starts counter into memory, number of times +1, exit program, counter close, store to file.
Because the confidence
JAVA learning lesson 38th (Common Object API)-set framework (6)-Map set and common methods
1. Map set features
The Map set (double row set) adds one element at a time, and the Collection set (single column set) adds one element at a time.Interface Map
Actually, key-value pairs are stored.
Features:
Objects that map keys to values. A ing cannot contain duplicate keys. Each key can only be mapped to one
to the diameter E is the base of the natural logarithm and these two do not need to be defined directlyImport Java.io.ioexception;import Java.util.random;public class Main {public static void main (string[] args) {Double D1 = M Ath.ceil (11.51);//returns the smallest integer greater than the parameter double D2 = Math.floor (11.51);//returns the largest integer less than the parameter double D3 = Math.Round (11.51);// Returns rounded System.out.println (D1); System.out.println (D2); SYSTEM.OUT.
Related knowledge:(1) Built-in objectsI. Use of the requestExample 1: Simple login Interface for informationExample 2: Get multi-valued information, such as hobbiesExample 3: Implementing a jump to get object informationSecond, to achieve user login(1) Get login information(2) Information verification processing(3) Different pages display login informationThird, the realization of user messagesUser message implementation: To implement the user message
there is no iterator, so how to get all the key-value pairs in the map (two methods)1. Through the Ketset () method (key Mastery), return a view of the keys contained in this map Set .Import Java.util.hashmap;import java.util.iterator;import Java.util.map;import Java.util.set;public class Main { public static void Main (string[] args) {mapThree steps.2. Pass entrySet() : Returns a view of the mappings contained in this map Set .import Java.util.hashmap;import java.util.iterator;import Java.util
maximum number of identical strings for a two stringImport java.util.scanner;/* * The longest common substring in two strings */public class main {public static void Main (string[] args) {string tstring = Compare (); System.out.println (tstring);} public static string compare () {string str1 = "VBABCDEFGSDFG"; String str2 = "ASDABCDEFGDF"; int mlen = Str1.length (); int zlen = Str2.length (); int len = (Mlen > Zlen)?zlen:mlen;//find a shorter string, the maximum public length will not exceed th
PackageCom.hero;ImportJava.lang.reflect.Field; Public classTestReflction5 { Public Static voidMain (string[] args) {Hero h=NewHero (); //Modify the value of name by using the traditional method GareenH.name = "Gareen"; Try { //Gets the field of the class hero named NameField f1= H.getclass (). GetField ("name"); //Modify the value of this fieldF1.set (H, "Teemo"); //Print the modified valueSystem.out.println (h.name); } Catch(Exception e) {//TODO auto-generated Catch blockE.printstack
; i Exercise 3: Two maximum identical substrings of a stringImport java.util.scanner;/* * The longest common substring in two strings */public class main {public static void Main (string[] args) {string tstring = Compare (); System.out.println (tstring);} public static string compare () {string str1 = "VBABCDEFGSDFG"; String str2 = "ASDABCDEFGDF"; int mlen = Str1.length (); int zlen = Str2.length (); int len = (Mlen > Zlen)? zlen:mlen;//find a shorter string, the maximum public length will not
Request Object:
Request has five (5) Collections, one (1) Property, and one (1) Method. You'll use the Collections far more than the property or the method.
Request Collections:
Below is a table of the Request Collections and descriptions of how they are used.
Request Collections
ClientCertificate
Request. ClientCertificate ("Key [Field]")Client security info for SSL encryption
Cookies
Request. Cookies ("cookieName ")H
() {System.out.println (num+ "... "+color);}} public class Main {public static void main (string[] args) {/* Complete the creation of the object and define the name of the object *///create a man entity, implement man BLF1 with the new keyword = new man ( );//define a man type variable Blf2,man is a class, BLF2 is a variable name//variable that is defined by a class, is a variable of class type, points to
("Ran.txt", "RW");//Throw abnormal raf.write ("Assad". GetBytes ());//Use the default character set of the platform to encode this String as a byte sequence and store the result in a new The byte array. Raf.writeint (97);//can write basic data type Byte, int accounts for 4 bytes three spaces +araf.write ("Adelaide". GetBytes ()); Raf.writeint (98); Raf.close ();}Random writes and detailspublic static void Randomwrite () throws Ioexception{randomaccessfile RAF = new Randomaccessfile ("Ran.txt",
(string[] args) {mans BLF = new Man (20); Man BLF2 = new Mans (20); Class C = Blf.getclass (); Class d = Blf2.getclass (); System.out.println (c); System.out.println (C==d);//true, the byte-code file object of two objects is the same as//class in the current runtime class name GetName (System.out.println ()) obtained by the C.getname method; /man}}Iv. tostring Method:Import Java.net.interfaceaddress;import javax.management.runtimeerrorexception;class
bigger share in the future.Ogg is a very small codec format, it produces files, the same length of time, but the size of the file is 10 times times smaller than the other formats, or even larger. However, there may be less use in environments where the quality of sound and video requirements are higher.To sum up, if we need to embed a video on our web page, we can use the source tag to introduce these three formats, while working with the Flash Player of the
memory leak, violate who calls who release principle }Therefore, the return pointer is generally not recommendedReturn Reference Analysis:myclass func3 () { MyClass C1; return C1; // Extreme Error, the end of the stack object dies New MyClass (); return *PC2; // There may be memory leaks, there are ways to get to the PC2, but the average person will not do, do not know to do }Returns a reference to an incoming parameter, OK and rec
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.