Basic Java Data

Source: Internet
Author: User
Tags object serialization serialization

1 // Time class date and Calendar
3 Date date=new// get current time the  methods in this class are basically obsolete and are replaced by the Calendar class, but can still be used.
5 Calendar c=calendar.getinstance ();  // the time class object is abstract so it can't be new. 6 Date date=c.gettime ();  // Get current Time 7 // adds or subtracts a specified amount of time for a given calendar field, based on the rules of the calendar. The current line is the number of days minus one
9 SimpleDateFormat sio=new// define time format
 One // Mathematical Class (NumberFormat) This class is the abstract base class for all numeric formats//you can set the fixed length of decimals and integers there are other ways to look at (API) ANumberFormat Nfor=numberformat.getnumberformat ();//because he's an abstract class that can't be new . -Nfor.setminimumintegerdigits (3);//set the integer portion at least three bits -Nfor.setminimumfractiondigits (5);//set the mantissa to 5 bits after the decimal point the //usage -NumberFormat nfor=Numberformat.getnumberformat (); -Nfor.setminimumintegerdigits (3);//set the integer portion at least three bits -Nfor.setminimumfractiondigits (5);//set the mantissa to 5 bits after the decimal point + LongI=1;//Define a variable - System.out.println (Nfor.format (i)); +
 A  at //random number randomly class -Random q=NewRandom ();//He is an ordinary class so you can call the new object based on the method inside the object. - //Common Methods -Q.nextint (100);//Randomly generate a random number within 100 -  - //The sorted collections class is a collection of collection helper classes in //basic method to sort and flip strings in ascending order -Collections.sort (s);//S is a collection of the data in the collection in ascending order toCollections.reverse (s);//S is a collection of the data in the collection is sorted in ascending order and the data in the flipped collection becomes descending +  - //Basic usage random number sort theArraylist<integer> s=NewArraylist<integer> ();//Define a collection *  for(inti=0;i<5;i++){ $Integer w=q.nextint (100);//Randomly generate 1-100 of random numbersPanax NotoginsengS.add (w);//Put the generated random number in the collection - } theCollections.sort (s);//Descending arrangement +  for(Integer integer:s) { A System.out.println (Xiao.format (integer)); the } +
 44  //   Collection class, in detail, see API   45  collection interface is Set , List, interface inherits  46  set interface is Hashset,treeset, class inherits S The data in the ET collection cannot be repeated  47  list interface is ArrayList, Linkedlist,vector, the class inherits the Vector and is inherited by the Stack interface. The data in this collection can be repeated  48  49  collection and Map are two interfaces that are lateral  50  51  map interface is HashMap, HashTable, TreeMap class inheritance  Span style= "COLOR: #008080" >52  hashtable interface is also inherited by Propertise class  53  
 Wu input and output byte stream, character stream, buffered stream, object flow - About //input and output stream, stream divided into two, 1-byte stream. 2 characters Stream $ 1 bytes of stream, byte stream read a bit at a time, under what circumstances can be used, if it is plain text, consider using a character stream should be loaded faster than the byte stream - 2 characters stream, character stream read one character at a time if it is plain text, you can consider using a character stream because the stream is loaded faster than the byte throttle - //the file class obtains the object and instance of the source file address: File File=new file ("F:/1.txt"); -Usage of Build stream: Fileinputstring file=NewFileinputstring (file)//(file) the stream under which the input stream is created from the source file object is the same A  // byte stream  +InputString input stream S.read ();//method of reading data int si=s.read (); //S is the name of the stream theOutputString output stream S.write ();//How to write Data -  // character Stream  $Reader input stream S.read ();//ways to read data theWriter output stream S.write ();//How to write Data the  the Close () The name of the method stream that closes the stream from large to small, close (), instance: S. Close (); the  - //The cache stream is divided into two types: the first byte and the second character in //when a cache stream is used, it is necessary to open a space in memory, and when the space is full, the data in the cache stream will be written out.  the //So when the cached data is not filled with buffers, we need to force the data in the buffer to be written out.  theMethods: F2.flush ();//F2 is the name of the cache. About 1-byte cache stream, theBufferedinputstream//byte input Cache stream theBufferedoutputstream//byte output cache stream the 2-character Cache stream, +BufferedReader//character input Cache stream -BufferedWriter//byte output cache stream the Bayi //Object Flow 、、、、 theObjectInputStream//Object Input Stream | Method of reading data Obj1.readobject (); theObjectOutputStream//Object Output Stream | Method of writing data Obj1.writeobject (SC); (SC) is the name of the object you want to write - //method of object flow input -Typ04_bean ps= (Typ04_bean) obj2.readobject ();//entity class: Typ04_bean, object name: PS the
 the // serializing a serialized class to implement this interface Serializable, the  attribute modified with the transient keyword will not be serialized with the concept of a  serialization:  Serialization is the process of converting an object's state into a format that can be persisted or transmitted. Contrary to serialization, deserialization is reversed, and he converts the stream into an object. The two processes combine to make it easy to store data.   in general, objects cannot be detached from the application. Sometimes, however, you need to keep the state of the object and restore the object when needed, that is, object persistence (Persistence). Object serialization  Serialization) can store objects in the external memory or in binary form over the network. The Crossdress object is an object that can be serialized from this data with the same state as the original object.



Basic Java Data

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.