Fetch Value for a Specific Key in Java IdentityHashMap

Arjun Thakur
Updated on 29-Jun-2020 13:10:08

2K+ Views

To fetch the value for a specific key, use the get() method.As a parameter, set the key you want to fetch and fetch the value.Let’s say you need to fetch value of key 3get("3")The following is an example to fetch the value for a specific key in Java IdentityHashMap −Example Live Demoimport java.util.*; public class Demo {    public static void main(String[] args) {       Map 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); ... Read More

Main Method Accept Arguments Other Than String Array in Java

Maruthi Krishna
Updated on 29-Jun-2020 13:08:04

5K+ Views

The public static void main() method accepts an array of values of the type String Java from the user.public class{    public static void main(String[] args){    } }You can pass them at the time of execution right after the class name separated with spaces as −java ClassName 10 20 30And, in the program (from the main method) you can extract these values from the String array and use.ExampleFor example, you can use command line arguments to pass a and b in the above program as −public class Sample {    public static void main(String[] args){       int ... Read More

SMTP Protocol Client in Python using smtplib

George John
Updated on 29-Jun-2020 13:05:39

1K+ Views

Python's standard library has 'smtplib' module which defines an SMTP client session object that can be used to send mail via Python program.A mail server is an application that handles and delivers e-mail over the internet. Outgoing mail servers implement SMTP, or Simple MailTransfer Protocol, servers which are an Internet standard for email transmission.Incoming mail servers come in two main varieties. POP3, or Post office protocol and IMAP, or Internet Message Access Protocol.smptlib.SMTP()functionThis function returns an object of SMTP class. It encapsulates and manages a connection to an SMTP or ESMTP server. Following arguments are defined in the signature of ... Read More

Change Return Type of Main Method in Java

Maruthi Krishna
Updated on 29-Jun-2020 13:05:29

3K+ Views

The public static void main() method is the entry point of the Java program. Whenever you execute a program in Java, the JVM searches for the main method and starts executing from it.You can write the main method in your program with return type other than void, the program gets compiled without compilation errors. But, at the time of execution JVM does not consider this new method (with return type other than void) as the entry point of the program.It searches for the main method which is public, static, with return type void, and a String array as an argument.public static int ... Read More

Why Main Method Must Be Static in Java

Maruthi Krishna
Updated on 29-Jun-2020 13:02:18

2K+ Views

Static − If you declare a method, subclass, block, or a variable static it is loaded along with the class.In Java whenever we need to call an (instance) method we should instantiate the class (containing it) and call it. If we need to call a method without instantiation it should be static. Moreover, static methods are loaded into the memory along with the class.In the case of the main method, it is invoked by the JVM directly, so it is not possible to call it by instantiating its class. And, it should be loaded into the memory along with the ... Read More

Add a Not Null Column in MySQL

Arjun Thakur
Updated on 29-Jun-2020 13:01:56

4K+ Views

You can add a not null column at the time of table creation or you can use it for an existing table.Case 1 − Add a not null column at the time of creating a table. The syntax is as followsCREATE TABLE yourTableName (    yourColumnName1 dataType NOT NULL,    yourColumnName2 dataType    .      .    .    N );The query to create a table is as followsmysql> create table NotNullAtCreationOfTable    -> (    -> Id int not null,    -> Name varchar(100)    -> ); Query OK, 0 rows affected (0.60 sec)In the above table, we ... Read More

Declare Main Method as Private, Protected or Without Access Modifier in Java

Maruthi Krishna
Updated on 29-Jun-2020 13:00:49

7K+ Views

Java provides various access specifiers namely private, public and protected etc...The Private modifier restricts the access of members from outside the class. A class and interface cannot be public.The Public access modifier can be associated with class, method, constructor, interface, etc. public can be accessed from any other class.The protected access modifier can be associated with variables, methods, and constructors, which are declared protected in a superclass can be accessed only by the subclasses in other package or any class within the package of the protected members' class.The default access modifier does not have keyword a variable or method declared ... Read More

Declare Main Method as Non-Static in Java

Maruthi Krishna
Updated on 29-Jun-2020 12:59:51

7K+ Views

The public static void main(String ar[]) method is the entry point of the execution in Java. When we run a .class file JVM searches for the main method and executes the contents of it line by line.You can write the main method in your program without the static modifier, the program gets compiled without compilation errors. But, at the time of execution JVM does not consider this new method (without static) as the entry point of the program.  It searches for the main method which is public, static, with return type void, and a String array as an argument.public static int main(String[] ... Read More

Declare Final Variables Without Initialization in Java

Maruthi Krishna
Updated on 29-Jun-2020 12:57:54

5K+ Views

In Java, final is the access modifier which can be used with a filed class and a method.When a method if final it cannot be overridden.When a variable is final its value cannot be modified further.When a class is final it cannot be extended.Declaring final variable without initializationIf you declare a final variable later on you cannot modify or, assign values to it. Moreover, like instance variables, final variables will not be initialized with default values.Therefore, it is mandatory to initialize final variables once you declare them.Still, if you try to declare final variables without initialization that will generate a ... Read More

Working of the 8257 DMA Controller

Vrundesha Joshi
Updated on 29-Jun-2020 12:56:38

2K+ Views

Initially the processor programs 8257. Here the processor behaves as the master and 8257 here works in the slave mode. The channel of the program is obtained by writing to the Address Register from the starting address of memory for transferring Data, and writing to the Counter Register where the number of bytes to be transferred is by using the Direct Memory Access Scheme. The number of bytes of information which is specified by the Least Significant 14 bits. Whereas The Most Significant 2 bits indicate what type of data transfer is to occur. After that the processor writes to ... Read More

Advertisements