- 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 34485 Articles for Programming
![Rishi Raj](https://www.tutorialspoint.com/assets/profiles/13777/profile/60_73169-1512647303.jpg)
92 Views
The removeAllElements() method is used to remove all components from this vector and sets its size to zero. This method is identical in functionality to the clear method.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); System.out.println("Added numbers are :- "); for (Integer number : vec) { System.out.println("Number = " + number); } System.out.println("Size of ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
60 Views
The removeElementAt(int index) method is used to delete the component at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously and the size of this vector is decreased by 1. Example public class VectorDemo { public static void main(String[] args) { Vector vec = new Vector(4); vec.add(4); vec.add(3); ... Read More
![Arushi](https://www.tutorialspoint.com/assets/profiles/13510/profile/60_55588-1512537391.jpg)
98 Views
The lastElement() method is used to return the last component of the vector.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); System.out.println("Last element: "+vec.lastElement()); } }OutputLast element: 1
![Paul Richard](https://www.tutorialspoint.com/assets/profiles/13505/profile/60_52698-1512536733.jpg)
93 Views
The firstElement() method is used to return the first component (the item at index 0) of this vector.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); System.out.println("First element is :"+vec.firstElement()); } }OutputFirst element is :4
![Vikyath Ram](https://www.tutorialspoint.com/assets/profiles/13780/profile/60_74413-1512648006.jpg)
171 Views
The elementAt(int index) method is used to get the component at the specified index/location of the vector.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); System.out.println("Element at 1st position :- "+vec.elementAt(1)); } }OutputElement at 1st position :- 3
![Rishi Raj](https://www.tutorialspoint.com/assets/profiles/13777/profile/60_73169-1512647303.jpg)
286 Views
The addElement(E obj) method is used to add the specified component to the end of this vector and increasing its size by one. The capacity of this vector is increased if its size becomes greater than its capacity. This addElement() method is identical in functionality to the add(Object) method. The add() method returns true/false but the addElement() method does not return any value.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); System.out.println("Initial ... Read More
![Johar Ali](https://www.tutorialspoint.com/assets/profiles/14293/profile/60_101691-1513053093.jpg)
317 Views
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.Syntaxswitch(expression) { case value : // Statements break; case value : // Statements break; // You can have any number of case statements. default : // Statements }The following rules apply to a switch statement −The variable used in a switch statement can only be integers, convertible integers (byte, short, char), ... Read More
![Pranav Indukuri](https://www.tutorialspoint.com/assets/profiles/512605/profile/60_2168928-1662357840.jpeg)
1K+ Views
A regular expression is a series of characters that allows you to discover a string or a set of strings using a search pattern. Regular expressions are sometimes known as RegEx. In Python, the re module is used to work with regular expressions. We can use repetitions in regular expression to match the string in python. To make repetitions possible in regular expression, we indicate the number of times the character is repeating in {}. Using search() function In the following example, we match ‘TTTTPPP’ string which is present in the string ‘TTTTTTPPPPPPPPPPPP’. Here, we have used T{4}P{3} to match ... Read More
![Rahul Sharma](https://www.tutorialspoint.com/assets/profiles/14297/profile/60_102977-1513054044.jpg)
157 Views
A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time.SyntaxFollowing is the syntax of a do...while loop −do { // Statements }while(Boolean_expression);Notice that the Boolean expression appears at the end of the loop, so the statements in the loop execute once before the Boolean is tested.If the Boolean expression is true, the control jumps back up to do statement, and the statements in the loop execute again. This process repeats until the Boolean expression is false.Examplepublic class Test { public static void main(String args[]) { ... Read More
![Pranav Indukuri](https://www.tutorialspoint.com/assets/profiles/512605/profile/60_2168928-1662357840.jpeg)
10K+ Views
A regular expression is a group of characters that allows you to use a search pattern to find a string or a set of strings. RegEx is another name for regular expressions. The re module in Python is used to work with regular expressions. To match the pattern over multiple lines in python by using regular expression, we use .* regular expression. Here, , indicates paragraph tag in HTML5. Implies zero or more occurrence of characters. . is a special character that matches all characters, including newline characters with the help of re.DOTALL flag. Generally, in regular ... Read More