Array:: Import Java - Util. Public Class Array (
Array:: Import Java - Util. Public Class Array (
Array:: Import Java - Util. Public Class Array (
Declaration of an array:
int num[]; or int num = new int[2];
Some times user declares an array and it's size simultaneously. You may or may not be define the size in
the declaration time. such as:
int num[] = {50,20,45,82,25,63};
In this program we will see how to declare and implementation. This program illustrates that the array
working way. This program takes the numbers present in the num[] array in unordered list and prints
numbers in ascending order. In this program the sort()function of the java.util.*; package is using to sort
all the numbers present in the num[] array. The Arrays.sort() automatically sorts the list of number in
ascending order by default. This function held the argument which is the array name num.
Vector instances are like linked-lists that can grow dynamically. Once it reaches the maximum limit,
resources are allocated dynamically and increases its size further.
Vector
The given below Syntax is used to declare an empty vector so that the size of internal data array has 10
and its standard storage capacity has zero.
public Vector()
The given Syntax is used to construct an empty vector specified by initial capacity.
The below Syntax Creates an empty vector with the specified initial capacity and capacity increment.
void add(int index, Object element)- Inserts the specified element at the specified position in this Vector
.
boolean add(object o)- Appends the specified element to the end of this Vector.
Vector trim to size( )- Trim the Capacity of Vector to vector's current size.
public int lastindexof(obj abc)-Returns the occurrence of last index of of the specified object in this vector.
This java example shows us to find a maximum element of Java Vector using max method of Collections
class. We Import required package, then declare a Class name maximum vector element .Inside the main
method create an object of vector. The object of vector class calls add method to add the component of
vector. In order to find the maximum element of vector component use, static object max(collection c)
method of collection class which we already imported the Collection package .This method returns the
maximum element of Java Vector.
import java.util.Vector;
import java.util.Collections;
char charAt(int index) : This method is used to get the character at the given index of a given
String.
int codePointAt(int index) : This method is used to find the Unicode of character at the given
index of a String.
int codePointBefore(int index) : This method is used to find the Unicode of character before the
given index of a String.
int codePointCount(int beginIndex, int endIndex) : This method is used to get the number of
Unicode points in the given text range of index of a String.
int compareTo(String anotherString) : This method compares two strings using Unicode value
of every characters. It compares the sequence of characters of Strings lexicographically.
int compareToIgnoreCase(String str) : This method compares two strings using Unicode value
of every characters. It compares the sequence of characters of Strings lexicographically by
ignoring case. The returned value of this method may be a negative integer, zero, or a positive
integer that demonstrates the comparing string is greater than, equal to or, less than the
compared String respectively.
Syntax : public int compareToIgnoreCase(String str)
String concat(String str) : This method is used to append the given string at the end of the
string.
boolean contentEquals(CharSequence cs) : This method is used to compare the String with
the given sequence of char.
boolean contentEquals(StringBuffer sb) : This method is used to compare the String with the
given StringBuffer.
static String copyValueOf(char[] data) : This method is used to get the String from the given
array of characters.
static String copyValueOf(char[] data, int offset, int count) : This method is used to get the
String from the given array of characters started from the specified index and the number of
characters.
Syntax : public static String copyValueOf(char[] data, int offset, int count)
boolean endsWith(String suffix) : This method is used to check whether the string is ends with
the given string.
Syntax : public boolean endsWith(String suffix)
boolean equals(Object anObject) : This method is used to check whether the String object is
equal to the given Object or not.
static String format(Locale l, String format, Object... args) : This method is used to format a
String using the given Locale, format string and arguments.
static String format(String format, Object... args) : This method is used to format a String
using the given format string and arguments.
byte[] getBytes() : This method is used to get the array of bytes after encoding the String.
byte[] getBytes(Charset charset) : This method is used to get the array of byte after encoding
the String with the given charset.
int hashCode() : This method is used to get the hash code of String.
int indexOf(int ch, int fromIndex) : This method is used to get the position of the first
occurrence of given character inside the String. In this method search operation is started from
the given position.
int indexOf(String str) : This method is used to get the position of the first occurrence of given
substring inside the String.
int indexOf(String str, int fromIndex) : This method is used to get the position of the first
occurrence of given substring inside the String. In this method search operation is started from
the given position.
boolean isEmpty() : This method is used to check whether the String has 0 (zero) length or not.
int lastIndexOf(int ch) : This method is used to get the last occurrence position of the given
character inside a String.
int lastIndexOf(int ch, int fromIndex) : This method is used to get the last occurrence position
of the given character inside a String. In this method the search is started from the given index.
int lastIndexOf(String str, int fromIndex) : This method is used to get the last occurrence
position of the given substring inside a String. In this method the search operation is started from
the given index.
int length() : This method is used to get the number of characters within the String.
boolean matches(String regex) : This method is used to match the string with the given regular
expression.
String replace(char oldChar, char newChar) : This method is used to replace the given old
character with the given new character.
String replaceAll(String regex, String replacement) : This method is used to replace all
substring of the String if the given regular expression is matched with the given replacement.
String[] split(String regex) : This method is used to split the string from the specified matching
regular expression.
boolean startsWith(String prefix) : This method is used to check whether the string is started
with the given string or not.
String substring(int beginIndex) : This method is used to get the string within the String called
substring. Substring is started from the given index.
String substring(int beginIndex, int endIndex) : This method is used to get the string within the
String called substring. This Substring is a part of the string specified within the starting index and
end index.
char[] toCharArray() : This method is used to convert a string into an array of characters.
String toLowerCase() : This method is used to convert the upper case characters to lower case.
String toUpperCase() : This method is used to convert the lower case characters to upper case.
Syntax : public String toUpperCase()
String trim() : This method is used to omit the whitespace around the String.
static String valueOf(Object obj) : This method is used to represent an object as a String.