CORE API / NOTES</>↗Core API08 Mar 2006
When we have an application that used a text file to store a configuration, and the configuration is typically in a key=value format then we can use java.util.Properties to read that configuration file. Here is an example of a configuration file called app.config: app.name=Properties Sample Code app.version=1.0 The code below show you how to read […]
CORE API / NOTES</>↗Core API06 Mar 2006
To convert collection-based object into an array we can use toArray() or toArray(T[] a) method provided by the implementation of Collection interface such as java.util.ArrayList. package org.kodejava.util; import java.util.List; import java.util.ArrayList; public class CollectionToArrayExample { public static void main(String[] args) { List<String> words = new ArrayList<>(); words.add("Kode"); words.add("Java"); words.add("-"); words.add("Learn"); words.add("Java"); words.add...
CORE API / NOTES</>↗Core API02 Mar 2006
To convert array based data into List / Collection based we can use java.util.Arrays class. This class provides a static method asList(T… a) that converts array into List / Collection. package org.kodejava.util; import java.util.Arrays; import java.util.List; public class ArrayAsListExample { public static void main(String[] args) { String[] words = {"Happy", "New", "Year", "2021"}; List<String> list […]
CORE API / NOTES</>↗Core API28 Feb 2006
The java.util.Calendar allows us to do a date arithmetic function such as add or subtract a unit of time to the specified date field. The method that done this process is the Calendar.add(int field, int amount). Where the value of the field can be Calendar.DATE, Calendar.MONTH, Calendar.YEAR. So this mean if you want to subtract […]
CORE API / NOTES</>↗Core API24 Feb 2006
To get the current month name from the system we can use java.util.Calendar class. The Calendar.get(Calendar.MONTH) returns the month value as an integer starting from 0 as the first month and 11 as the last month. This mean January equals to 0, February equals to 1 and December equals to 11. Let’s see the code […]
CORE API / NOTES</>↗Core API20 Feb 2006
When building a computer program we will use a lot of string to represent our data. The data might not just information about our customer name, email or address, but will also contain numeric data represented as string. So how do we know if this string contains a valid number? Java provides some wrappers to […]