Check Value Existence in Java IdentityHashMap

Chandu yadav
Updated on 30-Jul-2019 22:30:24

161 Views

Use the containsValue() method to check whether a particular value exists in IdentityHashMap or not.Create a IdentityHashMapMap m = newIdentityHashMap(); m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110); m.put("6", 50); m.put("7", 90); m.put("8", 250); m.put("9", 350); m.put("10", 450);Now, let’s say we need to check whether value 100 exists or not. For that, use the containsValue() method like thism.containsValue(100)The following is an example to check for the existence of a value in IdentityHashMapExample Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { Map m = newIdentityHashMap(); ... Read More

Find 2's Complement of Flag Register in 8085

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

426 Views

In this program we will see how to find 2's complement of the content of flag register.Problem StatementWrite 8085 Assembly language program to find 2's complement of the content of flag register.DiscussionWe cannot access the total flag register directly. To use them we have to push the PSW(Accumulator-Flag) into stack, and then pop it to another register pair, then after complementing the LS byte of that register pair, we have to push it again into the stack, and then pop it to PSW  to get it into Flag bits.InputHere we are not putting any input directly. If the flag bits ... Read More

Make Two Activities with Different Colored Status Bar in Android

Arjun Thakur
Updated on 30-Jul-2019 22:30:24

670 Views

There are so many situations, where we need to change the different action bar colors according toproject requirement . This example demonstrate about how to make Two activities with different colored status bar.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 created on button when you click on button it going to call second activity.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import ... Read More

Class Declaration with a Method That Has a Parameter in Java

Arushi
Updated on 30-Jul-2019 22:30:24

209 Views

A class declaration can contain a method that has a parameter in Java. A program that demonstrates this is given as follows:Example Live Democlass Message {    public void messagePrint(String msg) {       System.out.println("The message is: " + msg);    } } public class Demo { public static void main(String args[]) { Message m = new Message(); m.messagePrint("Java is fun"); } }OutputThe message is: Java is funNow let us understand the above program.The Message class is created with a single member ... Read More

Remove First Two Characters of All Fields in MySQL

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

926 Views

To remove the first two characters of all fields, you need to use SUBSTRING() function from MySQL. The syntax is as follows −UPDATE yourTableName SET yourColumnName=SUBSTRING(yourColumnName, 3) WHERE yourCondition;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table RemoveFirstTwoCharacterDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> StringValue varchar(30),    -> PRIMARY KEY(Id)    -> ); Query OK, 0 rows affected (1.04 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into RemoveFirstTwoCharacterDemo(StringValue) values('U:100'); Query OK, 1 ... Read More

Get First Day of Every Month in MySQL

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

222 Views

You can use date-format() function from MySQL to get the first day of every corresponding month. The syntax is as follows −select DATE_FORMAT(yourDatetimeColumnName ,'%Y-%m-01') as anyVariableName from yourTableName;To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table getFirstDayOfMonth -> ( -> DueDatetime datetime -> ); Query OK, 0 rows affected (1.16 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into getFirstDayOfMonth values(date_add(now(), interval 3 month)); Query OK, 1 row affected ... Read More

Get Age from D.O.B Field in MySQL

Arjun Thakur
Updated on 30-Jul-2019 22:30:24

5K+ Views

To get age from a D.O.B field in MySQL, you can use the following syntax. Here, we subtract the DOB from the current date.select yourColumnName1, yourColumnName2, ........N, year(curdate())- year(yourDOBColumnName) as anyVariableName from yourTableName;To understand the above syntax, let us first create a table. The query to create a table is as follows.mysql> create table AgeDemo -> ( -> StudentId int, -> StudentName varchar(100), -> StudentDOB date -> ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command. The query is as follows.mysql> insert into AgeDemo values(1, 'John', '1998-10-1'); Query OK, 1 ... Read More

Return a Shallow Copy of IdentityHashMap in Java

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

136 Views

Returning a shallow copy means to copy elements of one IdentityHashMap to another. For this, clone() method is used.The following is an example to return a shallow copy of IdentityHashMapExample Live Demoimport java.util.*; public class Demo { public static void main(String[] args) { IdentityHashMap m = newIdentityHashMap(); m.put("1", 100); m.put("2", 200); m.put("3", 300); m.put("4", 150); m.put("5", 110); m.put("6", 50); m.put("7", 90); m.put("8", 250); m.put("9", 350); m.put("10", 450); System.out.println("IdentityHashMap elements"+ m); System.out.println("Size = " + m.size()); System.out.println("Cloned Map = " + m.clone()); 0System.out.println("Size = " + m.size()); } }OutputIdentityHashMap elements {2=200, 4=150, 9=350, 7=90, 10=450, 6=50, 5=110, 8=250, 1=100, 3=300} Size = 10 Cloned Map = {2=200, 4=150, 9=350, 7=90, 10=450, 6=50, 5=110, 8=250, 1=100, 3=300} Size = 10

How Does the Microstrip Antenna Work

Knowledge base
Updated on 30-Jul-2019 22:30:24

2K+ Views

Microstrip antennas are the low-profile antennas. A metal patch mounted on a ground level with a dielectric material in-between constitutes a Microstrip or Patch Antenna. These are very low size antennas having low radiation. The patch antennas are popular for low profile applications at frequencies above 100MHz.Construction and workingThe microstrip consists of a very thin metallic strip placed on a ground plane with a dielectric material in-between. The radiating element and feed lines are placed by the process of photo-etching on the dielectric material. Usually, the patch or microstrip is chosen to be square, circular or rectangular in shape for ... Read More

Stop EditText from Gaining Focus at Activity Startup in Android

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

2K+ Views

There are so many situations where we don't required keyboard visibility when activity starts. This example demonstrate about how to Stop EditText from gaining focus at Activity startupStep 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 given on Edit Text. By Default it contains request focus.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.EditText; public class MainActivity extends ... Read More

Advertisements