1. A method for qualifying the end of a string (example: Let the end not contain,-,,)
while (Strtrue.endswith ("+") | | Strtrue.endswith ("-") | | Strtrue.endswith (","))//filter out the end of the + + number
Strtrue=strtrue.substring (0,strtrue.length ()-1);
2. Remember: For numbers to be compared with = =, for strings to be compared with. Equals (string), otherwise the comparison to = = is always No.
There is no length limit for the 3.String type, but the maximum length of String in the general JDK is 4G
5. In a Java class, you cannot use the property variables of a class in a static method.
6. For iterator interface
The iterator () method of the Collection interface returns a iterator. The iterator interface method can iterate through each element of the collection in an iterative manner and safely remove the appropriate element from the collection.
(1) Boolean hasnext (): To determine if there is another accessible element
Object Next (): Returns the next element to be accessed. If the end of the collection is reached, the nosuchelementexception exception is thrown.
(2) void Remove (): Deletes the object returned from the last access. This method must be executed immediately after the access of an element. If the collection has been modified since the last access, the method throws a illegalstateexception. The delete operation in iterator also has an effect on the underlying collection.
That is, under a hasnext (), do not call the. Next () method more than once, or it will appear: Nosuchelementexception exception.
7. For converting a string to an integer type, for a generic Integer.getinteger ("23"), it may be converted to a null, so it is first converted to an int using integer.parseint and then forced type conversion: New Integer (23) that is. 8. Show the time of a yyyy-mm-dd hh:mm
Import java.util.*;
public class test{
public static void Main (String srt[])
{
Date D=new date ();
GregorianCalendar z=new GregorianCalendar ();
Z.settime (d);
String Datetime=z.get (calendar.year) + "-" +z.get (calendar.month) + "-" +z.get (calendar.day_of_month) + "" +z.get ( Calendar.hour) + ":" +z.get (Calendar.minute);
System.out.println (DateTime);
System.out.println (D.tostring ());
}
} 9. For the number of double and float type to obtain the positive sign:
Math.sinnum (..);
The following are information from the class library
Class Math
Java.lang.Object
Java.lang.Math
There are some positive and negative methods which can solve your problem
Static Double Signum (double D)
Returns the Signum function of the argument; Zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero.
static float Signum (float f)
Returns the Signum function of the argument; Zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero.