To know where MySQL store database files, you can use the variable @@datadir. The query is as follows −mysql> select @@datadir;The following is the output that displays the path −+---------------------------------------------+ | @@datadir | +---------------------------------------------+ | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ | +---------------------------------------------+ 1 row in set (0.00 sec)Here is the snapshot where MySQL store database files i.e. the same path we got above −Now, let us verify whether ... Read More
The NavigableMap put() method is used to set a specific key and value in the NavigableMap.The following is an example to implement NavigableMap put() method −Example Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { NavigableMap n = new TreeMap(); n.put(5, "Tom"); n.put(9, "John"); n.put(14, "Jamie"); n.put(1, "Tim"); n.put(4, "Jackie"); n.put(15, "Kurt"); ... Read More
To get enumeration over HashSet, first declare the HashSet and add elements −HashSet hs = new HashSet(); hs.add("P"); hs.add("Q"); hs.add("R");To get enumeration −Enumeration e = Collections.enumeration(hs);The following is an example to get Enumeration over HashSet −Example Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { HashSet hs = new HashSet(); hs.add("P"); hs.add("Q"); hs.add("R"); Enumeration e = Collections.enumeration(hs); while (e.hasMoreElements()) System.out.println(e.nextElement()); } }OutputP Q R
Getting acquainted with local and foreign languages is opening the doors to plenty of opportunities. Languages like Hindi, Punjabi, Gujarati, Urdu, Tamil, Malayalam, Bengali and many other Indian languages as well as the foreign languages like French, German, Spanish, Arabic, Korean, Japanese, Chinese, Italian, Russian and Persian, etc. not only boost your chances of getting a job but also offer you an opportunity to get to know a completely diverse world with a unique viewpoint.Educational QualificationHowever, there is no educational qualification required to learn any language. You can choose any local or foreign language as a subject during your schooling. ... Read More
Instance variables are initialized using initialization blocks. However, the static initialization blocks can only initialize the static instance variables. These blocks are only executed once when the class is loaded. There can be multiple static initialization blocks in a class that is called in the order they appear in the program.A program that demonstrates a static initialization block in Java is given as follows:Example Live Demopublic class Demo { static int[] numArray = new int[10]; static { System.out.println("Running static initialization block."); for (int i = 0; i < numArray.length; i++) { ... Read More
To add 30 days to a value in the table, you can use ADDDATE() function with UPDATE command. The syntax is as follows:UPDATE yourTableName SET yourDateColumnName=ADDDATE(yourDateColumnName, INTERVAL 30 DAY);To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table Add30DayDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> ShippingDate date, -> PRIMARY KEY(ID) -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into Add30DayDemo(ShippingDate) values('2019-02-04'); Query OK, 1 row affected ... Read More
With Java, you can initialize a set without using add() method.For this create a string array −String arr[] = { "A", "B", "C", "D", "E"};Now, use Set and asList() method to initialize the above string array to our Set −Set s = new HashSet(Arrays.asList(arr));The following is an example to initialize a set without using add() method −Example Live Demoimport java.util.Arrays; import java.util.HashSet; import java.util.Set; public class Demo { public static void main(String[] a) { String arr[] = { "A", "B", "C", "D", "E"}; Set s = ... Read More
The synchronizedSet() method returns a synchronized (thread-safe) sorted set backed by the specified sorted set.First, create a HashSet and add elements −Set hs = new HashSet(); hs.add(29); hs.add(879); hs.add(88); hs.add(788); hs.add(456);Now, to get synchronized set, use the synchronizedSet() method −Set s = Collections.synchronizedSet(hs);The following is an example to get synchronized set from HashSet −Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]) { Set hs = new HashSet(); hs.add(29); hs.add(879); ... Read More
Sometimes we click back button unintentionally, When you click on a back button it will close your application or will go back to another activity. To avoid this problem, This example demonstrates how to make back button twice to close an activity.Step 1 - Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 - Add the following code to res/layout/activity_main.xml. Step 3 - Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.app.ActivityManager; import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.os.VibrationEffect; ... Read More
The static variable is a class level variable and it is common to all the class objects i.e. a single copy of the static variable is shared among all the class objects.A static method manipulates the static variables in a class. It belongs to the class instead of the class objects and can be invoked without using a class object.The static initialization blocks can only initialize the static instance variables. These blocks are only executed once when the class is loaded.A program that demonstrates this is given as follows:Example Live Demopublic class Demo { static int x = 10; ... Read More