Format Specifier for Hash Code in Java

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

150 Views

Format specifier for Hash Code us %h.Firstly, create a new object for Formatter and Calendar −Formatter f = new Formatter(); Calendar c = Calendar.getInstance();For hash code −f.format("%h", c)The following is an example that finds the hash code −Example Live Demoimport java.util.Calendar; import java.util.Formatter; public class Demo { public static void main(String args[]) { Formatter f = new Formatter(); Calendar c = Calendar.getInstance(); System.out.println("Hash Code: "+f.format("%h", c)); } }OutputHash Code: 4b899958

What is the significance of Ajanta Caves?

Rashmi Iyer
Updated on 30-Jul-2019 22:30:24

1K+ Views

The UNESCO Heritage site of Ajanta caves is located in Aurangabad, Maharashtra. These caves were excavated as a part of the first wave of cave architecture in India. It became an important center for Buddhist religion and art under the enlightened patronage of the Vakataka rulers. However, it is important to note that the excavations of these caves happened in different phases in different time periods beginning in the 2nd Century.The aerial view of the site looks like a horseshoe. This site was abandoned during the 6th-7th centuries and was rediscovered only during the British period by an Army officer ... Read More

Change One Cell's Data in MySQL?

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

322 Views

Update only one cell’s data with the help of UPDATE command. The syntax is as follows −UPDATE yourTableName yourColumnName=yourNewValue where yourColumnName=yourOldValue;To understand the above concept, let us first create a table. The query to create a table is as follows −mysql> create table changeCellsData    -> (    -> Id int,    -> Name varchar(100),    -> Age int    -> ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into changeCellsData values(101, 'Mike', 23); Query OK, 1 row affected (0.12 sec) mysql> insert into ... Read More

How to decrement a value in MySQL keeping it above zero?

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

3K+ Views

You can decrement value in MySQL with update command. With this, you can also restrict the value to not reach below 0.The syntax is as follows −update yourTableName set yourColumnName = yourColumnName - 1 where yourColumnName > 0;To avoid the value to go below zero, you can use yourColumnName > 0.To understand the above syntax, let us create a table. The query to create a table.mysql> create table DecrementDemo −> ( −> DecrementValue int −> ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table with insert statement. ... Read More

What are the duties of chief minister in Indian constitution?

Shanmukh Pasumarthy
Updated on 30-Jul-2019 22:30:24

724 Views

The elected head of the government of the states in India is called as the Chief Minister of that particular state or union territory. The governor appoints the Chief Minister following elections to the state legislative assembly. The party with the majority of votes will elect their leader, the candidate for Chief Minister, who is invited by the governor to swear in as Chief Minister of State. The Chief Minister's term lasts for typically for 5 years, or until next General Elections. However, there is no limit for the number of terms he can serve.To be eligible for the post ... Read More

8085 program to find maximum of two 8 bit numbers

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:24

533 Views

In this program we will see how to find the maximum of two numbers.Problem StatementWrite 8085 Assembly language program to find the maximum number of two 8-bit number stored at location 8000H and 8001H.DiscussionThis checking is done by using the CMP instruction. This instruction is very similar to the SUB instruction. The only difference is that it does not update the value of Accumulator after executing. So after comparing, if the CY flag is set, it means that the first number is smaller, and the second one is largerInputFirst inputAddressData......8000FD800123......second inputAddressData......800059800175......Flow DiagramProgramAddressHEX CodesLabelMnemonicsCommentsF00021, 00, 80LXI H, 8000HPoint to the first ... Read More

How to detect if an iOS application is in background or foreground?

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

3K+ Views

To detect if an iOS application is in background or foreground we can simply use the UIApplication just like we can use it to detect many other things like battery state, status etc.Let’s see how we can do this in our application. We’ll make use of shared resources of our Application which are stored in UIApplication.shared. We can use it like shown below −print(UIApplication.shared.applicationState)The shared.application state is an enum of type State, which consists of the following as per apple documentation.public enum State : Int {    case active    case inactive    case background }The case active means that ... Read More

MySQL date column auto fill with current date?

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

11K+ Views

You can use now() with default auto fill and current date and time for this. Later, you can extract the date part using date() function.Case 1:The syntax is as follows:yourDateColumnName date default ‘yourDateValue’;Case 2:The syntax is as follows:yourDateColumnName datetime default now();To understand the above, let us create a table. The query to create a table is as follows:mysql> create table DefaultCurrentdateDemo    -> (    -> LoginDate datetime default now()    -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command. The query is as follows:mysql> insert into DefaultCurrentdateDemo values(); Query OK, 1 ... Read More

Demonstrating variable-length arguments in Java

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

3K+ Views

A method with variable length arguments(Varargs) in Java can have zero or multiple arguments. Variable length arguments are most useful when the number of arguments to be passed to the method is not known beforehand. They also reduce the code as overloaded methods are not required.A program that demonstrates this is given as follows:Example Live Demopublic class Demo {    public static void Varargs(String... str) {       System.out.println("Number of arguments are: " + str.length);       System.out.println("The argument values are: ");       for (String s : str)          System.out.println(s);    } ... Read More

Get the record of a specific year out of timestamp in MySQL?

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

245 Views

You can get year out of timestamp using YEAR() function. The syntax is as follows −SELECT yourColumnName FROM yourTableName WHERE YEAR(yourTimestampColumnName)='yourYearValue’';To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table getYearOut    -> (    -> Id int NOT NULL AUTO_INCREMENT,    -> Name varchar(10),    -> yourTimestamp timestamp default current_timestamp,    -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (1.56 sec)Insert some records in the table using INSERT command−mysql> insert into getYearOut(Name, yourTimestamp) values('John', now()); Query OK, 1 row affected (0.26 sec) ... Read More

Advertisements