1.instanceof: test whether the left-hand object is an instance of the right class; Array. Length: Returns the length of the array;
2.Scanner class Nextint (): reads the integer of keyboard input; next (): Read the keyboard input string nextline (): Read the keyboard input line 3. Math class: int min (): to find the minimum value; int Max (): Max long round (): rounding; double ceil (): Rounding up; double floor (): Rounding down, 4.String class: int length (): returns the lengths of the strings; string trim (): used to remove whitespace at both ends of a string; string substring (): intercept string, header does not wrap tail; Boolean contains (): determine whether to include; String Concat (): Connection string; string[] split (): cut string; Char charAt (): returns the character at the index; int Indexat (): Returns the index of the first occurrence of the specified character; Endwith (): tests whether the specified suffix ends; matches (): The regular expression determines the string; replace (): Replace string, return a new string; 5.Random class: random random = new random (); Nextint (int maxValue ): generates a random number between [0,maxvalue]; nextdouble (): generates a random number of [0,1] 6. ArrayList class: Size (): Returns the length of the collection; add (): adds an element to the collection; get (): Gets the element at the specified position; Remove (int index): removes the element at the specified index; set (int index, element): sets the element at the specified index; 7.GUIJFrame class: setup form SetSize (): Set the form size; setlocation (): sets the form position; seTvisible (): sets the form to be visible; setresizable (false): Set Form size fixed setdefaultcloseoperation (jframe.exit_on_close): exits the program when the window is closed; Add (): Add button; setlayout (): set form layout; jlabel Titlelabel = new JLabel (new ImageIcon (" Fruitstore.jpg ")) Storage picture new ImageIcon (); JPanel class: Setup Panel SetLayout (): set layout; JButton class: Add button jdialog class: dialog window; Toolkit class: Toolkit kit = Toolkit.getdefaulttoolkit (); kit.getscreensize (): Get screen size; set form title Picture: Seticonimage (kit.createimage (titleimagepath)) JScrollPane class: get scroll bar setviewportview (table): Visual window jtable class: get table list JLabel class: get tag JTextField class: Get text box JTextArea class: get text field TableModel Class: data class Joptionpane Class: popup prompt Showmessagedialog (); showconfirmdialog (); JComboBox class: drop-down selection box AddItem (): Add optional; GetSelectedItem (): Gets the selected item; setselecteditem (): Set selected items; string[] thead = {"fruit number", "fruit name", "fruit Unit price", "unit"}; // string[][] tbody = { // {"9056", "thai Air transport big durian", "120.0", "a"}, // {"3025", "changping Farmhouse Organic strawberry", "20.0", "catty"}, // {"2021", "xinjiang Origin cantaloupe", "7.0", "jin"} // };//// Create a TableModel data object // /*// * TableModel Data class construction method, first parameter: table body data Second Parameter: table header data // * Public DefaultTableModel (string[][] tbody, string[] thead) // */// TableModel datamodel = new DefaultTableModel (tbody, thead); //// CREATE TABLE object, assign value to Member location table // table = new JTable (); //// jtable data (tablemodel) // table.setmodel (datamodel); // table.gettableheader (). setreorderingallowed (false); //column cannot be moved // table.gettableheader (). setresizingallowed (false); //non-pull table // table.setenabled (false); //non-change data tablepane.setbounds (a);//// put the list table into a viewport // tablepane.setviewportview (table); Common listener: * public void Addwindowlistener (windowlistener l) form event * public void Addkeylistener (keylistener L) Keyboard Event * public void Addmouselistener (mouselistener L) mouse event * public void Addfocuslistener (focuslistener l) Focus event * public void addActionListener (actionlistener L) button action Event 8. Date class: getTime (): get time; SetTime (): Set the time; Conversion between date and string* Overview of the A:dateformat class* DateFormat is an abstract class of date/time formatting subclasses that formats and resolves dates or times in a language-independent manner. * DateFormat is an abstract class, so use its subclasses SimpleDateFormat* Public final string format (date date): converts dates to string formats* Public Date parse (string source): converts a string to a date format9.Calendar class: Calendar class, Abstract class, cannot create objects Directly. getinstance (): Gets the Calendar class instance get (int field): gets the field value from the field date GetTime (): Calendar class to date class object Gettimesinmillis (): gets the millisecond value three ways to get time: System.out.println (new Date (). getTime ()); first Calendar c = calendar.getinstance (); second System . out.println (c.gettimeinmillis ());
System.out.println (system.currenttimemillis ()); the Third Kind
10.System class: currenttimemillis (): get time; Exit (int status): exit, status 0 o'clock is normal off GC (): garbage collection (not recommended) getProperties (): Returns the collection of Systems 11: Collection Class Collection: Single-column collection List:arraylist,li Nkedlist,vector set:hashset,treeset,hashtablemap: Dual-column Collection Hashmap,treemap * A: Adding features* Put (K key,v value): adds an element. * If the key is stored for the first time, the element is stored directly, returning null* If the key does not exist for the first time, replace the previous value with a value and return the previous value* B: Delete function* Void Clear (): removes all Key-value pair elements* V Remove (Object key): deletes the key value pair element according to the key, and returns the value* C: Judging function* Boolean ContainsKey (Object key): determines whether the collection contains the specified key (not spoken)* Boolean Containsvalue (Object value): determines whether the collection contains the specified value (not Speaking)* Boolean IsEmpty (): determines whether the collection is empty* D: Get function* set<map.entry<k,v>> EntrySet (): Gets the set set of all the Entry in the Map collection (not spoken)* V get (Object key): Gets the value according to the key* set<k> KeySet (): Gets a collection of all the keys in the collection (not Spoken)* collection<v> values (): gets a collection of all values in the collection (not Spoken)* E: length function* int size (): Returns the number of Key-value pairs in the collection 12.iterator iterators (interfaces) list.iterator (): get iterators by collection Hasnext (): Determine if there are elements next (): Remove the element remove (): remove element itrator is collection method, all Single-column collections can use Listiterator is the collection method of the list branch, the Set collection cannot be used! 13.Collections: Collection Tool class Shuffle (): elements in the collection shuffle order Sort (): sort the elements in the collection binarysearch (): find the index of an element AddAll (): add more than 14 elements to the Collection. Set set interface Keyset (): gets a collection of keys for a double-column collection; entryset (): Gets a double-column collection of key-value pairs for collection 15. File Class: a member of the IO stream that represents a file or folder exist (): determines whether a file or directory exists; Isfile (): Determine whether it is a file; Isdirectory (): Determine if it is a folder; getName (): Gets the name of the file or folder; file[] listfiles (): gets all sub-files or subfolders under the folder; string[] list (): Gets an array of file names; GetAbsolutePath (): Gets the absolute path of the file or folder; createnewfile (): Create new file length (): get file size; mkdir (): Create a single-level directory; mkdirs (): Create a multilevel directory; Delete (): deletes files or directories; renameto (): renaming; CanRead (): readable; canwrite (): is it possible toWrite ishidden (): whether hidden; LastModified (): Last modified time; get function with Filter:* Public string[] list (filenamefilter filter) list with filter * Public file[] listfiles (filenamefilter filter) listfiles with filter 16:arrays: the tool class that operates the array toString (): returns the contents of the array as a string representation; 17.desktop.ini: system files that can be directly recognized by the operating system for file Contents: [. shellclassinfo] iconfile= icon Path iconindex=0; Execute system commandruntime.getruntime (). exec ("attrib" + dir.getcanonicalpath () + "+s");runtime.getruntime (). exec ("attrib" + myini.getcanonicalpath () + "+s +h");18.JFileChooser class: File Selection showopendialog (): open window getselectfile (): get selected file Showsavedialog (): show save file selector 19. IO stream: IO Stream classification* A: Byte stream* Output stream: outputstream (abstract Class)|--fileoutputstream (class)* Input stream: inputstream (abstract Class)|--fileinputstream (class)* B: Character stream* Output stream: Writer (abstract Class)|--outputstreamwriter (conversion Stream)|--filewriter (basic character Stream)* Input stream: Reader (abstract Class)|--inputstreamreader (conversion Stream)|--filereader (basic character Stream) Efficient streaming: byte stream: bufferedinputstream/ Bufferedoutputstream (method and normal byte Stream) character Stream: bufferedreader: ReadLine (): Read line bufferedwriter: NewLine (): line break bytes Buffer stream: bytearrayinputstream/bytearrayoutputstream filereader: read (): reads one character at a time, returns the character itself, and reads back to the end-1; read (char[]): read character array FileFilter class: Create file name Filter: FileFilter Filter = new Filenameextensionfilter ("txt", "txt"); Set filter: chooser.setfilefilter (filter), 20.InetAddress class: Get IP address Getlocalhost (): Gets the local host address; gethostaddress (): Get IP address; GetHostName (): Get host name; getbyname (String host name): 21.Socket class: socket programming Client: SockeT (String ip,int port): client to specify the Server-side IP address and port getInputStream (): Gets the byte input stream; getoutputstream (): Gets the byte output stream; Shutdownoutput (): end tag Server side: serversocket (int port): Specify the port number for clients to find and ServerSocket Server = new ServerSocket (int port); socket socket = server.accept (); Gets the socket object for the client 22. Thread class: Start (): open thread; CurrentThread (): Gets the current thread; GetName (): Gets the current thread name; Sleep (long miliis): thread sleep setpriority (), set thread priority 23. Reentranlock: get lock object:, lock lock is more flexible to synchronize resolution reentrantlock r = new Reentrantlock (): r.lock (): get lock R.unlock (): release lock 24. Executorservice: thread pooling technology executorservice pool = executors.newfixedthreadpool (2) Creating a thread pool pool.submit (new myrunnable ()); put the thread into the pool and execute it; shutdown (); turn off thread pool 25. jdbc DriverManager class: registerdriver (new Driver ()): Register driver connection conn = drivermanager.getconnection (): Get connections Statement STAT = Conn. Createstatement (): Gets the object that can execute the SQL statement Preparedstatement: He is the sub-interface of statement, which provides the precompiled functionality, To prevent SQL injection attack issues ResultSet: result set object: next (): determine if there are elements use reflection to register the database driver: Class.forName ("com.mysql.jdbc.Driver"); connection pooling technology: Basicdatasource DataSource = new Basicdatasource (); datasource.setmaxidle (max_idle);//connection Pool Maximum number of idle connections
The main classes and methods in Javase