Core Java
文章平均质量分 74
iloveflowerll
这个作者很懒,什么都没留下…
展开
-
String vs StringBuffer vs StringBuilder in Java
http://javarevisited.blogspot.ca/2011/07/string-vs-stringbuffer-vs-stringbuilder.htmlString is one of the most important classes in Java and anyone who starts with java programming uses string to ...原创 2012-05-11 23:14:28 · 76 阅读 · 0 评论 -
regular expression
1、Java对反斜线处理的问题 在其他语言中,\\表示要插入一个字符\; 在Java语言中,\\表示要插入正则表达式的反斜线,并且后面的字符有特殊意义。 看API文档: 预定义字符类 . 任何字符(与行结束符可能匹配也可能不匹配) \d 数字:[0-9] \D 非数字: [^0-9] \s 空白字符:[ \t\...原创 2012-06-13 03:08:16 · 68 阅读 · 0 评论 -
Java各类型转换
各种数字类型转换成字符串型: String s = String.valueOf( value); // 其中 value 为任意一种数字类型。 字符串型转换成各种数字类型: String s = "169"; byte b = Byte.parseByte( s ); short t = Short.parseShort( s ); int i = Integ...原创 2012-06-13 05:25:44 · 85 阅读 · 0 评论 -
How to sort an array,mid of linkedlist, reverse int
A common mistake for a beginner to Java is to try and write some more or less complex method for sorting an array when in fact it can be done with just one line of code.The Arrays class has a static...原创 2012-06-13 07:47:01 · 103 阅读 · 0 评论 -
Lazy initialization
http://www.javapractices.com/topic/TopicAction.do;jsessionid=6E104A048475638493BA555238EC17F4?Id=34[code="java"]Lazy initialization is a performance optimization. It's used when data is deemed t...原创 2012-06-14 22:48:20 · 108 阅读 · 0 评论 -
Implementing hashCode; Transaction.java
[code="java"]Below is the syntax highlighted version of Transaction.java from § Algorithms. /************************************************************************* * Compilation: javac Tran...原创 2012-06-14 23:43:03 · 86 阅读 · 0 评论 -
Immutable objects
[code="java"]Immutable objects are simply objects whose state (the object's data) cannot change after construction. Examples of immutable objects from the JDK include String and Integer. Immutable...原创 2012-06-14 23:49:38 · 127 阅读 · 0 评论 -
Arrays.fill with multidimensional array in Java
[code="java"]How can I fill a multidimensional array in Java without using a loop? I've tried:double[][] arr = new double[20][4]; Arrays.fill(arr, 0); This results in java.lang.ArrayStoreExce...原创 2012-06-15 00:09:53 · 118 阅读 · 0 评论 -
When to use Comparable vs Comparator
[code="java"]I have a list of objects I need to sort on a field, say Score. Without giving much thought I wrote a new class that implements Comparator, that does the task and it works. Now looking...原创 2012-06-15 00:52:46 · 85 阅读 · 0 评论 -
Java Collection summary
Collection:List、Set Map:HashMap、HashTable 如何在它们之间选择 一、Array , Arrays Java所有“存储及随机访问一连串对象”的做法,array是最有效率的一种。 1、 效率高,但容量固定且无法动态改变。 array还有一个缺点是,无法判断其中实际存有多少元素,length只是告诉我们array的容量。 2、Jav...原创 2012-06-16 02:40:12 · 101 阅读 · 0 评论 -
5 Best Core java books you must read as a developer
If you want success in JAVA, you do not need to enroll in a class. You could save a lot of money by simply reading a good book. When you refer to a good JAVA book, you are also more likely to get deta...原创 2012-03-14 03:43:26 · 124 阅读 · 0 评论 -
string functions
[code="java"]import java.util.*;public class AppendEle { public List getAppendList(List inputList) { List result = new ArrayList(); StringBuilder tsb = new StringBuilder(); for (int...原创 2012-06-13 00:09:22 · 93 阅读 · 0 评论 -
String array to arraylist
There are some important things to note with the solutions given above: Garrett's solution, with Arrays.asList() is efficient because it doesn't need to copy the content of the array. This met...原创 2012-06-13 00:07:05 · 256 阅读 · 0 评论 -
How HashMap works in Java
Read more: http://javarevisited.blogspot.com/2011/02/how-hashmap-works-in-java.html#ixzz1uZl9vwENHow HashMap works in Java or sometime how get method work in HashMap is common interview questions ...原创 2012-05-11 23:40:49 · 84 阅读 · 0 评论 -
Difference between HashMap and HashTable? Can we make hashmap synchronized?
This question oftenly asked in interview to check whether candidate understand correct usage of collection classes and aware of alternative solutions available. 1. The HashMap class is roughly equ...原创 2012-05-12 01:32:51 · 73 阅读 · 0 评论 -
How to use Comparator and Comparable in Java? With example
Read more: http://javarevisited.blogspot.com/2011/06/comparator-and-comparable-in-java.html#ixzz1uaFRiHo5What is Difference between Comparator and Comparable in Java question was asked in a Test p...原创 2012-05-12 02:21:17 · 79 阅读 · 0 评论 -
10 example of using ArrayList in Java >>> Java ArrayList Tutorial
ArrayList in Java is most frequently used collection class after HashMap in Java. Java ArrayList represents an automatic resizable array and used in place of array. Since we can not modify size of an ...原创 2012-05-12 02:37:30 · 116 阅读 · 0 评论 -
Top 30 Programming interview questions
Programming questions are integral part of any java or C++ programmer or software analyst interview. No matter on which language you have expertise it’s expected that you are familiar with fundamental...原创 2012-05-12 02:48:16 · 84 阅读 · 0 评论 -
How to override equals method in Java
Object class holds some very interesting method which is applicable at object level and one of them is equals () which we are going to discuss in this article. equals () method is used to compare the ...原创 2012-05-12 02:57:59 · 137 阅读 · 0 评论 -
How to use getClass().getClassLoader().getResource()
This is the simplest wat to get the File object to which a certain URL object is pointing at:File file=new File(url.toURI()); Now, for your concrete questions:•finding all resources in the ...原创 2012-05-29 03:13:21 · 113 阅读 · 0 评论 -
Java高手必会的要点
http://developer.51cto.com/art/200907/136757.htmJava高手必会的要点1. 你需要精通面向对象分析与设计(OOA/OOD)、涉及模式(GOF,J2EEDP)以及综合模式。你应该了解UML,尤其是class、object、interaction以及statediagrams.2. 你需要学习Java语言的基础知识以及它的核心类库...原创 2012-05-29 03:28:35 · 80 阅读 · 0 评论 -
programming with String
Question:1) Write code to check a String is palindrome or not?以下是我一开始写的CODE,后来仔细一看就有很多问题了:public class CheckStringPalindrome { String original; public CheckStringPalindrome(String ...2012-06-12 01:43:17 · 82 阅读 · 0 评论 -
core java interview summary
http://blog.sina.com.cn/s/blog_3f4dc73b0100afub.html原创 2012-06-12 04:11:26 · 82 阅读 · 0 评论 -
install and uninstall java
How do I uninstall Java on my Windows computer ?-------------------------------------------------------------------------------- This article applies to: •Platform(s): Windows 7, Vista, Windows ...原创 2012-03-16 03:54:17 · 72 阅读 · 0 评论