1, how to get the current working directory?
String path=system.getproperty ("User.dir");
2. What is the difference between string x = "abc" and string x = new String ("abc")?
String x= "abc"; the x variable points to a string object in the data segment
string x = new String ("ABC") points to a string object in the heap, which must be copied into the object using a string in the data segment as a template;
3. What is the difference between string and StringBuffer?
String Immutable property, when we change it, does not change the contents of the string, but instead produces a new string object, less efficient,
The stringbuffer does not produce a new string, which is more efficient and is a buffer object;
4. How do I convert a string to a basic data type?
Data type variable = Data class. Parse Data type (the string);
5. How do I format the Date object for "2011-12-10" output? How do I convert a "2011-12-10" string to a date type?
SimpleDateFormat df=new SimpleDateFormat ("Yyyy-mm-dd");
String St=df.format (Date object);
System.out.println (ST);
Date D=df.parse (2011-12-10 ");
Java Fundamentals 9