,//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.
("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
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
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
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
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
(); Jdk1.6offerfrist () offerlast (); JDK1.5 before Getfrist (); Gets the first element (not deleted), if link is empty, throws a Nosuchelementexception exception getlast (); Jdk1.6peekfrist (): Gets the first element (not deleted) if link is empty, return nullpeeklast (); Jdk1.5removefrist (): Gets the first element and deletes if link is empty, throws Nosuchelementexception exception Removelast (): Jdk1.6pullfrist (): Gets the first element and deletes it, If link is empty, return Nullpulllas
is:" +mess);} }2) "some attention points of the class"A) "import statement"--"location" If the source file contains an import statement, it should be placed between the package statement and the class Definition. If there is no package statement, the import statement should be first in the source File.--the "scope" Import Statement and the package statement are valid for all classes defined in the source File. In the same source file, you cannot give different package declarations to differen
the E-containerThe object (it) must be dependent on the container for the element to be fetched, because the data structure of each container is different, so the iterator object must be implemented inside the container, and for the container holder, the implementation is unimportant, as long as the object of the iterator to the implementation is obtained throug
("span"). AddClass ("MyClass1"). End (). addclass ("MyClass2")3) $ ("P"). FIND ("span"). AddClass ("MyClass1"). Andself (). addclass ("MyClass2")A: 1) in all P tags, find the span tag for them plus the MYCLASS1 style, plus the MYCLASS2 style2) in all P tags, locate the span tag for them with the MyClass1 style, and then return to the previous object $ ("P"), and add the MyClass2 style to all P tags3) in all P tags, locate the span tag to add the MyCl
("span"). AddClass ("MyClass1"). End (). addclass ("MyClass2")3) $ ("P"). FIND ("span"). AddClass ("MyClass1"). Andself (). addclass ("MyClass2")A: 1) in all P tags, find the span tag for them plus the MYCLASS1 style, plus the MYCLASS2 style2) in all P tags, locate the span tag for them with the MyClass1 style, and then return to the previous object $ ("P"), and add the MyClass2 style to all P tags3) in all P tags, locate the span tag to add the MyCl
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.