Karthikeya Boyini has Published 2383 Articles

LocalDateTime plusWeeks() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

60 Views

An immutable copy of a LocalDateTime object where some weeks are added to it can be obtained using the plusWeeks() method in the LocalDateTime class in Java. This method requires a single parameter i.e. the number of weeks to be added and it returns the LocalDateTime object with the added ... Read More

Java Program to get Tail Map from TreeMap

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

83 Views

To get Tail Map from TreeMap, let us first create a TreeMap and set key-value pair −TreeMaptMap = new TreeMap(); tMap.put("1", "A"); tMap.put("2", "B"); tMap.put("3", "C"); tMap.put("4", "D"); tMap.put("5", "E"); tMap.put("6", "F"); tMap.put("7", "G");Now, let’s say you need to get the tailmap from 2 i.e. all the key-value pairs after ... Read More

Get the Current Working Directory in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

6K+ Views

The method java.lang.System.getProperty() is used to obtain the system property. This system property is specified by the key which is the parameter for the method. To obtain the current working directory, the key used is user.dir.A program that demonstrates this is given as follows −Example Live Demopublic class Demo {   ... Read More

CharBuffer hasArray() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

70 Views

It can be checked if a buffer has the backing of an accessible char array by using the method hasArray() in the class java.nio.CharBuffer. This method returns true if the buffer has the backing of an accessible int array and false otherwise.A program that demonstrates this is given as follows ... Read More

Change tinyint default value to 1 in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

1K+ Views

You can use DEFAULT command for this. Following is the syntax −alter table yourTableName change yourColumnName yourColumnName TINYINT(1) DEFAULT 1 NOT NULL;Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserName varchar(20),    UserAge int,    isMarried tinyint(1) ); ... Read More

LocalDateTime equals() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

72 Views

The equality of two LocalDateTime objects can be determined using the equals() method in the LocalDateTime class in Java. This method requires a single parameter i.e. the LocalDateTime object to be compared. Also it returns true if both the LocalDateTime objects are equal and false otherwise.A program that demonstrates this ... Read More

Java Program to put value to a Property list

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

232 Views

First, set properties and use put() to put value to property list −Properties p = new Properties(); p.put("India", "1983"); p.put("Australia", "1987"); p.put("Pakistan", "1992"); p.put("Srilanka", "1996");Now, display the properties key and value pairs −Sets = p.keySet(); for (Object record: s) System.out.println(record + " / " + p.getProperty((String) record));Exampleimport java.util.Properties; import java.util.Set; ... Read More

Create temporary file with specified extension suffix in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

854 Views

A temporary file with the specified extension suffix can be created using the method java.io.File.createTempFile(). This method requires two parameters i.e. the prefix to define the file name and the suffix to define the file extension. It also returns the abstract path name for the temporary file created.A program that ... Read More

How to see spaces in data when selecting with MySQL command line client?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

152 Views

Use quote() function for this. The syntax is as follows −select yourColumnName, quote(yourColumnName) from yourTableName;To understand the concept, let us create a table. The query to create a table is as follows −mysql> create table seeSpacesDemo    -> (    -> spaceValue varchar(10)    -> ); Query OK, 0 rows ... Read More

CharBuffer arrayOffset() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

63 Views

The offset of the first element of the buffer inside the buffer array is obtained using the method arrayOffset() in the class java.nio.CharBuffer. If the buffer backed by the array is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; ... Read More

Advertisements