Anton Saburov Студенческий отдел кадров
воскресенье, 22 мая 2011 г.
четверг, 17 декабря 2009 г.
Настройки java
Системные настройки
Environment Variables
JAVA_HOME = C:\Program Files\Java\jdk1.5.0
ANT_HOME = D:\apps\ant
PATH = %ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH%
среда, 25 ноября 2009 г.
String
Вывод с параметрами
char x = 'x';
int cast = (int)x;
int codePoint = String.valueOf(x).codePointAt(0);
char again = (char)codePoint;
System.out.printf("x = %s cast = %d codePoint = %d again = %s%n",
x, cast, codePoint, again);
if ( s.equals ( "abc" ) ) echo ( "matched" );
Java Glossary | String
воскресенье, 15 ноября 2009 г.
Джавские фишечки
\n - new line "\n"
\t - табулятор "\t"
\u2192, \u204B - знаки вопроса ? "\u2192" etc
Escape Sequences
toString
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
четверг, 29 октября 2009 г.
Loop time
2.21 ГГц, 1.00 ГБ ОЗУ
100000000
19:50:41
19:50:48
1000000000
19:51:33
19:52:37
10000000000
19:54:01
20:04:41
package loop_test;
import java.util.Calendar;
import java.text.SimpleDateFormat;
public class loop_test {
public loop_test() {
}
//public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
//public static final String DATE_FORMAT_NOW = "dd-MMMM-yyyy HH:mm:ss";
public static final String DATE_FORMAT_NOW = "HH:mm:ss";
public static void main(String[] args) {
loop_test lt = new loop_test();
Long j = 0L;
Long n = 10000000000L;
System.out.println(n);
System.out.println(lt.now());
for (Long i = 0L; i < n; i++) {
j++;
Math.sqrt(j);
}
System.out.println(lt.now());
}
public String now() {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
return sdf.format(cal.getTime());
}
}
среда, 8 апреля 2009 г.
java.lang.OutOfMemoryError
JDeveloper running a simple Java class threw:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
This is a standard java exception treated by adding parameters to java in command line as the default parameters are -Xms32m -Xmx128m.
This case solution was found in a discussion about analogous exception for embedded OC4J.
Just edit Run Configuration adding -Xms512m -Xmx1024m (for example) in Project Properties... | Run/Debug | Edit... | Java Options edit bar