public:computer:java
This is an old revision of the document!
Table of Contents
Java
String→StringBuilder
java.util.Date↔java.time.Instantjava.util.Calendar→java.time.Instantjava.text.SimpleDateFormatjava.time- Local
- Zoned
- Offset
- Collections
- List; ArrayList, LinkedList
- Set; HashSet, LinkedHashSet
- Map; HashMap, LinkedHashMap
- 람다식
(자료형 인수, ...) -> { ... 임의의 처리 ...}
Database
import java.sql.*;
...
...
Connection conn = null;
try
{
Class.forName("DRIVER");
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
try
{
conn = DriverManager.getConnection("jdbc database", "user", "password");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("QUERY");
while(rset.next())
{
// do something
}
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
if(conn != null)
{
try
{
conn.close();
conn = null;
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
...
...
- conn.setAutoCommit(true/false);
- conn.commit();
- conn.rollback()
- PreparedStatement stmt = conn.prepareStatement(“…. ?”);
- stmt.setString(1, “value”);
- DAOData Access Object
- DTOData Transfer Object
- JPAJava Persistence API
File I/O
- FileReader
- BufferedReader
- Scanner
- Files
- CSV, XML, LOGGER
Tests
- JUint
- @Test
- @Before
- @After
- @BeforeClass
- @AfterClass
- @Ignore
- import static org.junit.Assert.*;
- assertEquals()
- fail()
- assertThat()
- import static org.hamcrest.CoreMatchers.*;
- is()
- JMockit
- DbUnit
Reserved Words
- data types <list-group>
- byte
- short
- int
- long
- float
- double
- char
- boolean
- void
</list-group>
- class & packages <list-group>
- class
- interface
- enum
- package
- import
- extends
- implements
- this
- super
- new
</list-group>
- modifiers <list-group>
- public
- protected
- private
- static
- final
- abstract
- native
- volatile
- transient
- synchronized
- strictfp
</list-group>
- operations <list-group>
- if
- else
- switch
- case
- default
- for
- while
- do
- break
- continue
- return
- instanceof
- assert
</list-group>
- exceptions <list-group>
- try
- catch
- finally
- throw
- throws
</list-group>
- others <list-group>
- const
- goto
</list-group>
References
public/computer/java.1663250769.txt.gz · Last modified: by alex