最常用的1000个Java类(附代码示例)

分析Github 3000个开源项目,粗略统计如下。括号内的数字是使用频率 0-3000. 下面的列表显示不全,完整的请看完整列表

1.java.util.List (2889)

2.java.util.ArrayList (2831)
3.java.io.IOException (2813)
4.java.util.Map (2592)
5.java.util.HashMap (2541)
6.java.io.File (2195)
7.java.io.InputStream (2125)
8.java.util.Arrays (2068)
9.java.util.Collections (2028)
10.java.util.Set (2019)
11.java.util.Iterator (1954)
12.java.util.Collection (1734)
13.java.util.HashSet (1721)
14.java.util.Date (1679)
15.java.net.URL (1548)
16.java.io.FileInputStream (1495)
17.org.junit.Test (1463)
18.java.io.BufferedReader (1432)
19.java.io.OutputStream (1391)
20.java.io.InputStreamReader (1389)
21.java.io.FileOutputStream (1378)
22.java.util.regex.Pattern (1314)
23.java.io.FileNotFoundException (1294)
24.java.io.Serializable (1257)
25.java.lang.reflect.Method (1229)
26.java.io.ByteArrayOutputStream (1206)
27.java.util.LinkedList (1194)
28.java.util.Properties (1157)
29.java.text.SimpleDateFormat (1103)
30.java.io.ByteArrayInputStream (1079)
31.java.util.regex.Matcher (1064)
32.java.io.UnsupportedEncodingException (1047)
33.java.util.Locale (1009)
34.java.util.Comparator (1007)
35.org.junit.Before (1005)
36.java.util.Enumeration (949)
37.java.io.PrintWriter (931)
38.java.util.Random (928)
39.java.lang.reflect.InvocationTargetException (918)
40.java.net.MalformedURLException (916)
41.java.util.Map.Entry (899)
42.java.util.Calendar (859)
43.java.io.StringWriter (819)
44.java.lang.reflect.Field (790)
45.java.util.LinkedHashMap (788)
46.java.net.URI (781)
47.junit.framework.TestCase (720)
48.java.io.Reader (717)
49.java.io.Writer (706)
50.java.util.concurrent.TimeUnit (699)
51.java.io.FileReader (691)
52.java.io.FileWriter (682)
53.java.io.StringReader (680)
54.java.util.logging.Logger (677)
55.java.lang.reflect.Constructor (664)
56.java.text.ParseException (649)
57.java.net.URISyntaxException (644)
58.javax.servlet.http.HttpServletRequest (636)
59.java.lang.annotation.Retention (635)
60.java.util.TreeSet (632)
61.org.slf4j.Logger (627)
62.java.util.concurrent.ConcurrentHashMap (625)
63.java.io.OutputStreamWriter (622)
64.java.util.TreeMap (621)
65.java.util.StringTokenizer (619)
66.org.slf4j.LoggerFactory (618)
67.java.text.DateFormat (607)
68.android.os.Bundle (605)
69.org.junit.After (605)
70.javax.servlet.http.HttpServletResponse (603)
71.android.content.Context (603)
72.java.io.BufferedInputStream (600)
73.java.security.NoSuchAlgorithmException (592)
74.java.util.logging.Level (589)
75.java.lang.annotation.Target (588)
76.java.util.concurrent.Executors (588)
77.org.xml.sax.SAXException (586)
78.android.util.Log (583)
79.java.util.Vector (583)
80.android.content.Intent (578)
81.org.junit.runner.RunWith (577)
82.android.app.Activity (575)
83.javax.servlet.ServletException (568)
84.android.view.View (567)
85.java.lang.annotation.RetentionPolicy (559)
86.java.util.Hashtable (559)
87.java.security.MessageDigest (553)
88.junit.framework.Assert (548)
89.org.junit.Assert (548)
90.java.io.PrintStream (546)
91.java.net.InetAddress (537)
92.java.util.UUID (526)
93.android.widget.TextView (524)
94.java.net.URLEncoder (521)
95.org.w3c.dom.Document (521)
96.java.lang.annotation.ElementType (520)
97.java.net.UnknownHostException (518)
98.java.nio.charset.Charset (516)
99.java.io.BufferedWriter (513)
100.java.util.concurrent.ExecutorService (503)
101.javax.xml.parsers.DocumentBuilderFactory (487)
102.java.nio.ByteBuffer (481)
103.java.io.ObjectInputStream (481)
104.java.util.concurrent.atomic.AtomicInteger (467)
105.java.io.ObjectOutputStream (467)
106.android.widget.Toast (466)
107.java.util.NoSuchElementException (466)
108.org.w3c.dom.Element (463)
109.java.util.LinkedHashSet (461)
110.java.io.BufferedOutputStream (461)
111.java.math.BigInteger (459)
112.android.os.Handler (451)
113.org.junit.BeforeClass (450)
114.android.content.SharedPreferences (449)
115.android.content.DialogInterface (449)
116.android.view.ViewGroup (444)
117.java.math.BigDecimal (443)
118.java.lang.reflect.Modifier (441)
119.android.net.Uri (437)
120.javax.xml.parsers.ParserConfigurationException (437)
121.java.net.Socket (436)
122.android.app.AlertDialog (436)
123.org.w3c.dom.NodeList (428)
124.java.util.Stack (428)
125.android.widget.Button (428)
126.javax.xml.parsers.DocumentBuilder (427)
127.java.net.URLConnection (426)
128.android.view.LayoutInflater (423)
129.org.w3c.dom.Node (422)
130.java.util.TimeZone (422)
131.java.sql.SQLException (421)
132.android.widget.ListView (406)
133.org.xml.sax.InputSource (405)
134.org.apache.log4j.Logger (398)
135.android.view.MenuItem (394)
136.android.widget.ImageView (394)
137.org.apache.http.HttpResponse (389)
138.org.apache.http.impl.client.DefaultHttpClient (388)
139.java.net.HttpURLConnection (387)
140.org.junit.Ignore (386)
141.java.net.InetSocketAddress (385)
142.android.util.AttributeSet (383)
143.java.lang.reflect.Array (383)
144.android.view.View.OnClickListener (380)
145.android.widget.AdapterView (376)
146.android.widget.EditText (374)
147.android.database.Cursor (374)
148.android.view.Menu (374)
149.android.graphics.Bitmap (372)
150.java.io.DataInputStream (366)
151.java.io.DataOutputStream (362)
152.java.util.zip.ZipEntry (357)
153.android.widget.LinearLayout (354)
154.javax.servlet.http.HttpServlet (352)
155.java.text.DecimalFormat (350)
156.java.util.concurrent.Callable (350)
157.org.apache.commons.lang.StringUtils (349)
158.java.io.FilenameFilter (346)
159.java.util.GregorianCalendar (346)
160.java.text.MessageFormat (344)
161.java.awt.Color (340)
162.android.view.KeyEvent (337)
163.java.lang.annotation.Annotation (336)
164.java.net.URLDecoder (336)
165.java.util.concurrent.Future (335)
166.android.graphics.drawable.Drawable (332)
167.android.content.res.Resources (331)
168.java.util.concurrent.atomic.AtomicBoolean (329)
169.android.preference.PreferenceManager (328)
170.android.widget.ArrayAdapter (327)
171.android.view.MotionEvent (326)
172.org.apache.commons.logging.Log (325)
173.java.util.ResourceBundle (324)
174.android.app.Dialog (324)
175.org.apache.commons.logging.LogFactory (321)
176.java.util.concurrent.ExecutionException (320)
177.java.lang.ref.WeakReference (320)
178.android.graphics.Canvas (319)
179.java.sql.ResultSet (319)
180.android.os.AsyncTask (317)
181.org.apache.http.client.methods.HttpGet (317)
182.java.sql.Connection (317)
183.java.util.Queue (315)
184.java.io.Closeable (313)
185.android.content.ContentValues (311)
186.java.util.ListIterator (311)
187.android.content.BroadcastReceiver (307)
188.org.apache.commons.io.IOUtils (305)
189.android.content.pm.PackageManager (301)
190.android.preference.PreferenceActivity (299)
191.org.junit.AfterClass (299)
192.android.os.Message (296)
193.android.graphics.Color (295)
194.java.net.ServerSocket (295)
195.org.json.JSONObject (294)
196.org.apache.http.client.HttpClient (292)
197.java.util.TimerTask (291)
198.java.util.concurrent.CountDownLatch (289)
199.android.app.ProgressDialog (287)
200.java.awt.event.ActionEvent (287)
201.javax.servlet.ServletContext (285)
202.android.view.Window (285)
203.java.util.Timer (285)
204.android.graphics.BitmapFactory (281)
205.android.database.sqlite.SQLiteDatabase (278)
206.java.awt.image.BufferedImage (276)
207.android.os.IBinder (276)
208.java.lang.reflect.Type (275)
209.java.util.SortedSet (274)
210.android.content.ComponentName (273)
211.java.text.NumberFormat (272)
212.android.app.PendingIntent (271)
213.java.awt.event.ActionListener (269)
214.org.osgi.framework.BundleContext (269)
215.java.util.concurrent.LinkedBlockingQueue (267)
216.java.util.concurrent.atomic.AtomicLong (267)
217.android.text.TextUtils (267)
218.org.json.JSONException (265)
219.org.apache.commons.io.FileUtils (264)
220.javax.servlet.ServletRequest (263)
221.org.apache.http.HttpEntity (263)
222.android.widget.BaseAdapter (263)
223.android.os.Build (263)
224.java.util.zip.GZIPInputStream (260)
225.java.awt.Dimension (259)
226.org.xml.sax.Attributes (258)
227.android.widget.AdapterView.OnItemClickListener (257)
228.android.os.Environment (257)
229.java.util.concurrent.CopyOnWriteArrayList (256)
230.java.io.FileFilter (255)
231.javax.xml.transform.stream.StreamResult (255)
232.android.app.Service (253)
233.android.app.ListActivity (252)
234.android.view.Gravity (251)
235.javax.swing.JPanel (251)
236.javax.swing.JFrame (250)
237.javax.servlet.ServletResponse (249)
238.android.database.sqlite.SQLiteOpenHelper (249)
239.java.security.SecureRandom (248)
240.android.graphics.Rect (247)
241.junit.framework.Test (246)
242.java.net.URLClassLoader (245)
243.junit.framework.TestSuite (245)
244.android.graphics.Paint (245)
245.org.apache.http.client.methods.HttpPost (244)
246.java.util.concurrent.BlockingQueue (243)
247.java.util.concurrent.ConcurrentMap (242)
248.javax.imageio.ImageIO (241)
249.android.content.pm.PackageManager.NameNotFoundException (241)
250.java.util.EnumSet (238)
251.java.nio.channels.FileChannel (236)
252.javax.xml.transform.TransformerFactory (236)
253.java.util.concurrent.locks.ReentrantLock (236)
254.android.view.WindowManager (234)
255.android.content.ContentResolver (234)
256.java.sql.PreparedStatement (234)
257.org.json.JSONArray (234)
258.javax.inject.Inject (233)
259.android.content.IntentFilter (233)
260.java.util.WeakHashMap (233)
261.javax.swing.JLabel (232)
262.java.net.SocketException (232)
263.javax.xml.transform.Transformer (231)
264.android.view.ContextMenu (229)
265.javax.servlet.http.HttpSession (228)
266.java.lang.reflect.Proxy (228)
267.java.io.EOFException (227)
268.java.sql.Statement (226)
269.android.widget.ImageButton (222)
270.java.io.RandomAccessFile (220)
271.android.content.res.Configuration (220)
272.javax.sql.DataSource (219)
273.android.widget.CheckBox (217)
274.com.google.common.collect.Lists (216)
275.android.app.Application (215)
276.org.xml.sax.helpers.DefaultHandler (214)
277.java.util.concurrent.atomic.AtomicReference (214)
278.javax.xml.transform.dom.DOMSource (213)
279.javax.persistence.Entity (213)
280.android.preference.Preference (213)
281.android.app.Notification (212)
282.org.codehaus.jackson.map.ObjectMapper (212)
283.javax.swing.JOptionPane (212)
284.android.os.SystemClock (212)
285.org.springframework.beans.factory.annotation.Autowired (211)
286.java.lang.reflect.InvocationHandler (211)
287.javax.servlet.FilterChain (210)
288.java.util.SortedMap (209)
289.android.os.Parcelable (207)
290.android.app.NotificationManager (207)
291.org.springframework.context.ApplicationContext (204)
292.javax.persistence.Id (203)
293.android.view.MenuInflater (203)
294.java.awt.BorderLayout (203)
295.android.widget.ProgressBar (202)
296.java.awt.event.MouseEvent (202)
297.java.sql.DriverManager (201)
298.org.apache.http.params.HttpParams (201)
299.android.graphics.Typeface (200)
300.java.util.jar.JarFile (200)
301.java.util.concurrent.ThreadFactory (199)
302.java.awt.Component (196)
303.android.graphics.drawable.BitmapDrawable (195)
304.java.util.concurrent.Executor (194)
305.java.lang.reflect.ParameterizedType (194)
306.javax.servlet.Filter (192)
307.javax.servlet.FilterConfig (192)
308.javax.swing.JButton (192)
309.android.content.pm.PackageInfo (191)
310.java.util.concurrent.TimeoutException (190)
311.java.util.Scanner (188)
312.org.apache.commons.codec.binary.Base64 (188)
313.android.widget.FrameLayout (188)
314.java.util.jar.JarEntry (187)
315.java.util.zip.ZipFile (187)
316.java.awt.Graphics2D (186)
317.java.awt.Font (186)
318.java.awt.Graphics (185)
319.java.lang.ref.SoftReference (185)
320.java.security.cert.X509Certificate (184)
321.java.security.Principal (184)
322.javax.naming.NamingException (184)
323.android.webkit.WebView (183)
324.android.view.animation.Animation (183)
325.android.content.res.TypedArray (181)
326.java.util.concurrent.locks.Lock (181)
327.javax.xml.parsers.SAXParserFactory (181)
328.javax.swing.JScrollPane (181)
329.org.testng.annotations.Test (180)
330.java.util.concurrent.ScheduledExecutorService (179)
331.java.util.MissingResourceException (178)
332.android.view.ContextMenu.ContextMenuInfo (178)
333.javax.xml.transform.TransformerException (178)
334.com.google.common.collect.Maps (178)
335.android.content.ActivityNotFoundException (177)
336.android.widget.CompoundButton (177)
337.android.os.Parcel (176)
338.javax.net.ssl.SSLContext (175)
339.android.view.animation.AnimationUtils (174)
340.org.apache.http.Header (174)
341.android.content.pm.ResolveInfo (172)
342.java.security.cert.CertificateException (171)
343.java.sql.Timestamp (171)
344.java.security.AccessController (171)
345.java.awt.event.WindowEvent (171)
346.android.content.SharedPreferences.Editor (170)
347.java.awt.event.KeyEvent (169)
348.android.graphics.RectF (169)
349.android.view.ViewGroup.LayoutParams (169)
350.org.w3c.dom.NamedNodeMap (169)
351.java.lang.management.ManagementFactory (168)
352.org.xmlpull.v1.XmlPullParserException (168)
353.javax.servlet.http.Cookie (168)
354.android.os.Looper (166)
355.org.xmlpull.v1.XmlPullParser (166)
356.java.util.concurrent.locks.ReentrantReadWriteLock (166)
357.javax.xml.bind.annotation.XmlRootElement (166)
358.java.util.concurrent.ConcurrentLinkedQueue (164)
359.android.widget.ListAdapter (164)
360.javax.swing.JTextField (164)
361.java.util.BitSet (163)
362.javax.xml.parsers.SAXParser (163)
363.java.util.concurrent.ThreadPoolExecutor (163)
364.javax.servlet.ServletConfig (163)
365.java.util.zip.ZipInputStream (162)
366.android.net.ConnectivityManager (162)
367.java.beans.PropertyChangeListener (161)
368.org.osgi.framework.Bundle (159)
369.javax.naming.InitialContext (159)
370.java.awt.Image (158)
371.org.apache.http.params.BasicHttpParams (158)
372.javax.persistence.EntityManager (158)
373.java.util.zip.ZipOutputStream (157)
374.java.security.PrivilegedAction (157)
375.java.nio.CharBuffer (157)
376.javax.swing.ImageIcon (157)
377.java.beans.PropertyDescriptor (157)
378.javax.xml.bind.JAXBContext (153)
379.com.google.common.base.Function (153)
380.javax.management.ObjectName (153)
381.org.apache.http.client.ClientProtocolException (152)
382.android.widget.Spinner (152)
383.android.content.DialogInterface.OnClickListener (152)
384.javax.persistence.GeneratedValue (151)
385.javax.swing.SwingUtilities (151)
386.javax.xml.namespace.QName (151)
387.android.os.RemoteException (150)
388.org.eclipse.swt.SWT (150)
389.android.text.Editable (150)
390.org.eclipse.swt.widgets.Composite (149)
391.org.mockito.Mockito (149)
392.org.springframework.core.io.Resource (149)
393.android.content.ContentProvider (149)
394.android.graphics.Matrix (149)
395.android.widget.RelativeLayout (148)
396.javax.servlet.ServletOutputStream (148)
397.com.google.common.collect.Sets (147)
398.org.apache.http.message.BasicNameValuePair (147)
399.java.util.EventListener (147)
400.javax.xml.transform.OutputKeys (146)
401.java.awt.Point (146)
402.java.beans.PropertyChangeEvent (146)
403.android.provider.BaseColumns (145)
404.javax.swing.JComponent (145)
405.org.apache.http.NameValuePair (144)
406.javax.swing.BorderFactory (144)
407.org.joda.time.DateTime (144)
408.javax.persistence.Column (144)
409.javax.ws.rs.Path (143)
410.org.apache.http.util.EntityUtils (143)
411.java.io.DataInput (143)
412.javax.annotation.PostConstruct (143)
413.org.xml.sax.XMLReader (143)
414.org.apache.http.params.HttpConnectionParams (142)
415.org.junit.Rule (142)
416.org.apache.commons.httpclient.HttpClient (142)
417.javax.xml.bind.annotation.XmlElement (142)
418.android.util.DisplayMetrics (141)
419.javax.xml.transform.stream.StreamSource (141)
420.android.media.AudioManager (140)
421.android.content.pm.ActivityInfo (140)
422.org.eclipse.ui.plugin.AbstractUIPlugin (139)
423.com.google.inject.Inject (139)
424.java.security.KeyStore (139)
425.org.springframework.test.context.ContextConfiguration (139)
426.com.google.common.base.Preconditions (139)
427.javax.net.ssl.TrustManager (139)
428.javax.naming.Context (138)
429.org.apache.hadoop.conf.Configuration (138)
430.java.io.FilterInputStream (138)
431.org.osgi.framework.BundleActivator (138)
432.android.view.ViewConfiguration (138)
433.android.database.SQLException (138)
434.javax.servlet.ServletContextEvent (138)
435.android.util.TypedValue (138)
436.