Remove Key-Value Pair from HashMap in Java

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

326 Views

Let’s say the following is our HashMap −HashMapmap = new HashMap();Add key value pair to the HashMap −map.put("1", "A"); map.put("2", "B"); map.put("3", "C"); map.put("4", "D"); map.put("5", "E"); map.put("6", "F"); map.put("7", "G"); map.put("8", "H"); map.put("9", "I");Now, use the remove() method to remove the key-value pair −map.remove("5");Example Live Demoimport java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; public class Demo {    public static void main(String[] args) {       HashMapmap = new HashMap();       map.put("1", "A");       map.put("2", "B");       map.put("3", "C");       map.put("4", "D");       map.put("5", "E"); ... Read More

Select First Word in a MySQL Query

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

5K+ Views

To select first word in MySQL query, you can use SUBSTRING_INDEX(). Following is the syntax −select substring_index(yourColumnName, ' ', 1) as anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentFullName varchar(40) ); Query OK, 0 rows affected (0.61 sec)Insert records in the table using insert command −mysql> insert into DemoTable(StudentFullName) values('John Smith'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(StudentFullName) values('Carol Taylor'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(StudentFullName) values('Bob Williams'); Query OK, 1 row affected (0.13 sec) mysql> insert ... Read More

Command Mode in 8085 Microprocessor

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

742 Views

We have seen previously that the linker is invoked in three modes i.e. they are command line mode, prompt mode and data file mode. For the linker to be run in this mode we type ‘LINK85 -C MULT.OBJ’ along with the change of address. In the above command simply “MULT” is enough instead of the command ‘MULT.OBJ’. We run the linker in this Command Mode type as by simply the following steps: Simply ‘MULT’ is more than enough instead of ‘MULT.OBJ’ in the command above. The linker in running command mode is indicated by the option -C. The command which ... Read More

Demerits of I/O Mapped I/O and Merits of Memory Mapped I/O

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

1K+ Views

Before having a discussion regarding the demerits of I/O mapped I/O and merits of memory-mapped I/O, let us have a generic discussion regarding the difference between I/O mapped I/O and memory mapped I/O.In Memory Mapped Input Output −We allocate a memory address to an Input-Output device.Any instructions related to memory can be accessed by this Input-Output device.The Input-Output device data are also given to the Arithmetic Logical Unit.Input-Output Mapped Input Output −We give an Input-Output address to an Input-Output deviceOnly IN and OUT instructions are accessed by such devices.The ALU operations are not directly applicable to such Input-Output data.So as ... Read More

Write Image File in Internal Storage in Android

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

6K+ Views

This example demonstrates How to write an image file in internal storage 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 button. When user click on button, It will store data in internal storage.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.content.Context; import android.content.ContextWrapper; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Button; import ... Read More

Upgrade MySQL Server from Command Line

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

3K+ Views

First, you need to open the CMD with the help of shortcut key Windows+R key.After typing cmd, press the OK button. On pressing, you will get a command prompt. The screenshot is as follows −After that, you need to reach the /bin directory. Follow the below instructions. If you are a Windows user, then use the below query to reach the /bin directory.The query is as follows −mysql> select @@datadir;The following is the output displaying the path −+---------------------------------------------+ | @@datadir ... Read More

Get Current Address from Network Provider in Android

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

363 Views

This example demonstrate about How to get current address 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 address.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; import android.widget.TextView; ... Read More

Verify Action Bar Title Truncation in Android

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

343 Views

This example demonstrates How to verify action bar tittle is truncating or not 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 text view to action bar tittle status.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; ... Read More

LocalTime plusSeconds Method in Java

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

93 Views

An immutable copy of a LocalTime object where some seconds are added to it can be obtained using the plusSeconds() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of seconds to be added and it returns the LocalTime object with the added seconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.now();       System.out.println("The current LocalTime is: " + lt);       System.out.println("The LocalTime with 5 seconds added is: ... Read More

Alter MySQL Column from VARCHAR(30) to VARCHAR(100)

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

652 Views

You need to use ALTER TABLE command along with MODIFYThe syntax is as followsALTER TABLE yourTableName MODIFY COLUMN yourColumnName varchar(100) NOT NULL;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table syntaxOfAlterCommandDemo    -> (    -> UserId int,    -> UserName varchar(30),    -> UserAge int,    -> UserCityName varchar(50)    -> ); Query OK, 0 rows affected (0.51 sec)Let us check the description of the table.The query is as followsmysql> desc syntaxOfAlterCommandDemo;The following is the output+--------------+-------------+------+-----+---------+-------+ | Field | Type ... Read More

Advertisements