Track Order of Insertion Using Java Collections

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

311 Views

To track the order of insertion, you can use Map.Entry() in case of a Map. Let’s say we have the following LinkedHashMap −Mapmap = new LinkedHashMap(); map.put("Jack", 0); map.put("Tim", 1); map.put("David", 2); map.put("Tom", 3); map.put("Kevin", 4); map.put("Jeff", 5);Now, loop through Map.Entry and get the order of insertion correctly with Key and Value −for (Map.Entryentry: map.entrySet()) {    System.out.println(entry.getKey() + " => " + entry.getValue()); }Example Live Demoimport java.util.LinkedHashMap; import java.util.Map; public class Demo {    public static void main(String[] args) {       Mapmap = new LinkedHashMap();       map.put("Jack", 0);       map.put("Tim", 1);       ... Read More

Remove Duplicate Records Except a Single Record in MySQL

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

1K+ Views

You can use DELETE command with some condition for this since we need to keep one record and delete rest of the duplicate records.Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(40) ); Query OK, 0 rows affected (0.48 sec)Insert records in the table using insert command −mysql> insert into DemoTable(StudentName) values('John'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(StudentName) values('Carol'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(StudentName) values('Sam'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable(StudentName) ... Read More

Pin Details and Address Range in 8085 Microprocessor

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

2K+ Views

Let us assume that we have a RAM chip of 2K x 8, It signifies that, we have 2 x 1024 = 2048 memory locations having information of 8 bits at each location. For selecting one of 2K = 211 memory locations in chip, there should be exactly input pins of 11 address lines. For bidirectional data transfer scheme, there should be eight pin involved in this process. The processor action involved in it is signified by the input pins RD* and WR*. Two pins are specified for grounding process of the pin and connecting of Direct Current of +5 ... Read More

Trap Interrupt Pin in 8085

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

5K+ Views

A non-maskable interrupt is a Trap Interrupt which implies that whenever this pin gets activated, the 8085 always gets interrupted even if the state of 8085 is in DI. The input of Trap input is level sensitive and edge sensitive. Hence the Trap line always makes a transition from 0 to 1, and remains in state 1 until the end of the execution of an instruction for the interruption of 8085. A vectored-interrupt in 8085 is a TRAP. The starting address of 8085 is known by itself the of the ISS as 4.5 * 8 = 0024H. Hence we name the ... Read More

Android Device RAM Management: Low vs High RAM

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

357 Views

This example demonstrate about How to android device is having low ram or high ram.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.     In the above code, we have taken text view to show device is low ram device or high ram.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ActivityManager; import android.content.Context; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.telephony.TelephonyManager; import android.view.WindowManager; import android.widget.TextView; public class MainActivity ... Read More

Get Current Country Code from Network Provider in Android

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

3K+ Views

This example demonstrates about How to get the current country code from Network provider in android.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.     In the above code, we have taken a text view to show the current country code.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.Manifest; import android.content.pm.PackageManager; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.location.LocationManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; ... Read More

The contains Method of the Java LabelValue Tuple

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

124 Views

Use the contains() method of the LabelValue class in Java to search for a value. The return value of the method is TRUE if the value exists in the tuple, else the FALSE value is returned.Let us first see what we need to work with JavaTuples. To work with LabelValue class in JavaTuples, you need to import the following package−import org.javatuples.LabelValue;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below ... Read More

ArrayBlockingQueue toArray Method in Java

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

117 Views

The toArray() method of the ArrayBlockingQueue class returns an array containing all of the elements in this queue.The syntax is as follows:Object[] toArray()To work with ArrayBlockingQueue class, you need to import the following package:import java.util.concurrent.ArrayBlockingQueue;The following is an example to implement toArray() method of Java ArrayBlockingQueue class:Example Live Demoimport java.util.ArrayList; import java.util.concurrent.ArrayBlockingQueue; public class Demo {    public static void main(String[] args) throws InterruptedException {       ArrayBlockingQueue q = new ArrayBlockingQueue(10);       q.add(200);       q.add(310);       q.add(400);       q.add(450);       q.add(500);       q.add(550);       q.add(700); ... Read More

Heap Overflow and Stack Overflow in C

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

6K+ Views

Heap OverflowHeap is used to store dynamic variables. It is a region of process’s memory. malloc(), calloc(), resize() all these inbuilt functions are generally used to store dynamic variables.Heap overflow occurs when −A) If we allocate dynamic large number of variables −int main() {    float *ptr = (int *)malloc(sizeof(float)*1000000.0)); }B) If we continuously allocate memory and do not free after using it.int main() {    for (int i=0; i

Get Current Language in Android Device

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

2K+ Views

While doing internalization in android application, we should know what is the current language in android device. This example demonstrate about how to Get the current language in Android device.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.         In the above code we have taken Button. When user click on button, it will take device country name and language and append to text view.Step 3 − Add the following code ... Read More

Advertisements