Karthikeya Boyini has Published 2193 Articles

Check the frequency of an element in Java with Collections.frequency

karthikeya Boyini

karthikeya Boyini

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

240 Views

Create a List in Java −List< String >list = Arrays.asList("P", "Q", "R", "P", "T", "P", "U", "V", "W", "X", "W" );Now, let’s say you want to get the frequency of element P. For that, use the Collections.frequency() method −Collections.frequency(list, "P");A shown above, we can find the occurrence of any letter ... Read More

Do Double Equal Sign exist in MySQL?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

There is no double equal sign concept. It can be used to compare two values. If you use double equal sign(==) in MySQL, you will get an error message.Let us verify the concept is true or not. Declare a variable −mysql> set @Number=10; Query OK, 0 rows affected (0.00 sec)Now, ... Read More

LocalDateTime plusWeeks() method in Java

karthikeya Boyini

karthikeya Boyini

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

108 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

156 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

7K+ 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

119 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

2K+ 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

172 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

Create temporary file with specified extension suffix in Java

karthikeya Boyini

karthikeya Boyini

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

1K+ 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

203 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

Advertisements