What Does the Method pop Do in Java

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

567 Views

The pop() method is used to remove the object at the top of this stack and returns that object as the value of this function. Example import java.util.*; public class StackDemo { public static void main(String args[]) { Stack st = new Stack(); st.push("Java"); st.push("Source"); st.push("code"); System.out.println("Removed object is: "+st.pop()); System.out.println("Elements after remove: "+st); } } Output Removed object is: code Elements after remove: [Java, Source]

Difference Between Java and Core Java

radhakrishna
Updated on 30-Jul-2019 22:30:21

1K+ Views

Java is a programming language, whereas Core Java is a computing platform. Java Platform Standard Edition is Core Java, which is also called Java SE. The following are the computing following supported by Java, which also has Core Java as its part:Java SE Java Standard Edition used to develop desktop applications. A well-known implementation of Java SE is the Java Development Kit (JDK).Java EE Java Enterprise Edition i.e. Java 2 Platform, Enterprise Edition or J2EE. Java EE is used for applications running on servers. Java ME Java Micro Edition is used for applications running on mobile phones.Java SE is the Standard Edition and also ... Read More

Set PRIMARY KEY on Multiple Columns of a MySQL Table

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

947 Views

Actually, MySQL allows us to set PRIMARY KEY on multiple columns. The advantage of doing this is that we can work on multiple columns as a single entity. Example We have created the table allotment by defining composite PRIMARY KEY on multiple columns as follows − mysql> Create table allotment( RollNo Int, Name Varchar(20), RoomNo Int, PRIMARY KEY(RollNo, RoomNo)); Query OK, 0 rows affected (0.23 sec) mysql> Describe allotment; +--------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+-------+ | RollNo ... Read More

Why Use Restrict Qualifier in C++

Abhinanda Shri
Updated on 30-Jul-2019 22:30:21

287 Views

There's no such keyword in C++. List of C++ keywords can be found in section 2.11/1 of C++ language standard. restrict is a keyword in the C99 version of C language and not in C++.In C, A restrict-qualified pointer (or reference) is basically a promise to the compiler that for the scope of the pointer, the target of the pointer will only be accessed through that pointer (and pointers copied from it).C++ compilers also support this definition for optimization purposes, but it is not a part of the official language specification.

Initialize and Compare Strings in Java

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

212 Views

You can compare Strings using compareTo() method or, equals() method or, or == operator. Following example demonstrates how to initialize and compare strings in Java. Example Live Demo public class StringDemo { public static void main(String[] args) { String str1 = "tutorials"; String str2 = "point"; // comparing str1 and str2 int retval = str1.compareTo(str2); // prints the return value of the comparison if (retval < 0) { System.out.println("str1 is greater than str2"); } else if (retval == 0) { System.out.println("str1 is equal to str2"); } else { System.out.println("str1 is less than str2"); } } } Output str1 is less than str2

String compare by equals Method in Java

Jai Janardhan
Updated on 30-Jul-2019 22:30:21

168 Views

The equals() method of the String class compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.Example Live Demopublic class Test {    public static void main(String args[]) {       Integer x = 5;       Integer y = 10;       Integer z =5;       Short a = 5;       System.out.println(x.equals(y));       System.out.println(x.equals(z));       System.out.println(x.equals(a));    } }Outputfalse true false

Add FOREIGN KEY Constraint to Existing MySQL Table

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

2K+ Views

We can add a FOREIGN KEY constraint to a column of an existing MySQL table with the help of ALTER TABLE statement. Syntax ALTER TABLE table_name ADD FOREIGN KEY (colum_name) REFERENCES table having Primary Key(column_name); Example Suppose we want to add a FOREIGN KEY constraint on the table ‘Orders1’ referencing to the table ‘Customer’ which have column ‘Cust_Id’ as the Primary Key. It can be done with the help of the following query − mysql> Alter table orders1 add FOREIGN KEY(Cust_id) REFERENCES Customer(Cust_id); Query OK, 0 rows affected (0.21 sec) Records: 0  Duplicates: 0  Warnings: 0   mysql> ... Read More

Use Week Input Type in HTML

Sai Subramanyam
Updated on 30-Jul-2019 22:30:21

471 Views

The week input type is used in HTML using the . Using this, allow users to select a week and year. A date picker popup is visible whenever you will give a user input to the week input type. Note − The input type week is not supported in Firefox and Internet Explorer. It works on Google Chrome. You can try to run the following code to learn how to use week input type in HTML. It will show both week and year. Example Live Demo HTML input week Details: Student Name Training week

Append Method in Java

Moumita
Updated on 30-Jul-2019 22:30:21

3K+ Views

The append(char c) method of the java.lang.StringBuffer appends the string representation of the char argument to this sequence. The argument is appended to the contents of this sequence. The length of this sequence increases by 1.Example Live Demoimport java.lang.*; public class StringBufferDemo {    public static void main(String[] args) {       StringBuffer buff = new StringBuffer("tuts ");       System.out.println("buffer = " + buff);             // appends the char argument as string to the string buffer.       buff.append('A');             // print the string buffer after appending ... Read More

MySQL Temporary Tables and Session End Behavior

seetha
Updated on 30-Jul-2019 22:30:21

163 Views

Temporary table would be deleted if MySQL session terminates. After login again, on issuing the SELECT command we will find no data available in the database. Even our temporary table will not exist.

Advertisements