- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4338 Articles for Java 8
289 Views
The search(Object o) method is used to return the 1-based position where an object is on this stack.Exampleimport 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("Searching 'code' in stack: "+st.search("code")); } }OutputSearching 'code' in stack:
393 Views
The get(int index) method of the java.util.ArrayList class returns the element at the specified position in this list.Exampleimport java.util.ArrayList; public class ArrayListDemo { public static void main(String[] args) { ArrayList arrlist = new ArrayList(5); arrlist.add(15); arrlist.add(22); arrlist.add(30); arrlist.add(40); for (Integer number : arrlist) { System.out.println("Number = " + number); } int retval=arrlist.get(3); System.out.println("Retrieved element is = " + retval); } }OutputNumber = 15 Number = 22 Number = 30 Number = 40 Retrieved element is = 40
100 Views
The empty() method is used to test if this stack is or not.Exampleimport 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("Is stack empty: "+st.empty()); } }OutputIs stack empty: false
206 Views
The peek() method is used to look at the object at the top of this stack without removing it from the stack.Exampleimport 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("Top object is: "+st.peek()); } }OutputTop object is: code
778 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
379 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]
98 Views
The toArray() method of the java.util.ArrayList class returns an array containing all of the elements in this list in proper sequence (from first to the last element).This acts as a bridge between array-based and collection-based APIs.Exampleimport java.util.ArrayList; public class ArrayListDemo { public static void main(String[] args) { ArrayList arrlist = new ArrayList(5); arrlist.add(20); arrlist.add(40); arrlist.add(10); arrlist.add(15); arrlist.add(25); for (Integer number : arrlist) { System.out.println("Number = " + number); } Object[] ... Read More
406 Views
The push(Object item) method is used to Pushes an item onto the top of this stack.Exampleimport 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("Elements in the stack: "+st); } }OutputElements in the stack: [Java, Source, code]
100 Views
The elements() method is used to return an enumeration of the components of this vector. The returned Enumeration object will generate all items in this vector at the similar index location.Exampleimport java.util.Vector; public class VectorDemo { public static void main(String[] args) { Vector vec = new Vector(4); vec.add(4); vec.add(3); vec.add(2); vec.add(1); Enumeration e=vec.elements(); System.out.println("Numbers in the enumeration are :- "); while (e.hasMoreElements()) { System.out.println("Number = " + e.nextElement()); } } }OutputNumbers in the enumeration are :- Number = 4 Number = 3 Number = 2 Number = 1