SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

CORE API / NOTES</>↗
Core API21 Jul 2006

How do I get number of days in a month?

Let say you want to know the number of days in a month, or we can say it as the last date of a month. The example below shows you how to obtain the number of days or the date. package org.kodejava.util; import java.util.Calendar; public class MonthDaysExample { public static void main(String[] args) { // […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API21 Jul 2006

How do I create random number?

The java.lang.Math.random() method returns random number between 0.0 and 1.0 including 0.0 but not including 1.0. By multiplying Math.random() result with a number, for example 10 will give us a range of random number between 0.0 and 10.0. To get a random number between two numbers (n and m) we can use the formula of: […]

Wayan · 2 min read
JDBC / NOTES</>↗
JDBC20 Jul 2006

How do I query records from a table?

package org.kodejava.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class JdbcQueryExample { // Database connection information private static final String URL = "jdbc:mysql://localhost/kodejava"; private static final String USERNAME = "kodejava"; private static final String PASSWORD = "s3cr*t"; public static void main(String[] args) { // Get a connection to database. try (Connection connection = [...

Wayan · 2 min read
AWT / NOTES</>↗
AWT18 Jul 2006

How do I get my screen size?

package org.kodejava.awt; import java.awt.*; public class ScreenSizeExample { public static void main(String[] args) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); System.out.println("Screen Width: " + screenSize.getWidth()); System.out.println("Screen Height: " + screenSize.getHeight()); } } The output of the code snippet above: Screen Width: 2560.0 Screen Height: 1080.0

Wayan · 1 min read
CORE API / NOTES</>↗
Core API14 Jul 2006

How do I determine if a pathname is a directory?

To determine if an abstract pathname is a directory we can use the File.isDirectory() method. Here is an example code. package org.kodejava.io; import java.io.File; public class IsDirectoryExample { public static void main(String[] args) { // Creates a instance of File. File file = new File("C:/Users/wsaryada"); // Check if the abstract pathname is a directory by […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API13 Jul 2006

How do I get total space and free space of my disk?

package org.kodejava.io; import java.io.File; public class FreeSpaceExample { public static void main(String[] args) { // We create an instance of a File to represent a partition // of our file system. For instance here we used a drive D: // as in Windows operating system. File file = new File("D:"); // Using the getTotalSpace() we […]

Wayan · 1 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.