AmitDiwan has Published 11365 Articles

StringTokenizer methods in Java

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 11:32:32

262 Views

The StringTokenizer class allows an application to break a string into tokens. Following are the methods −Sr.NoMethod & Description1int countTokens()This method calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.2boolean hasMoreElements()This method returns the same value as the hasMoreTokens method.3boolean hasMoreTokens()This method tests ... Read More

HTML DOM Textarea autofocus Property

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 11:29:46

116 Views

The HTML DOM Textarea autofocus property returns and modify whether the text area should automatically get focused or not when the page loads.SyntaxFollowing is the syntax −1. Returning autofocusobject.autofocus2. Modifying autofocusobject.autofocus = true | falseLet us see an example of HTML DOM Textarea autofocus Property:Example    body { ... Read More

Traverse through a HashMap in Java

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 11:25:42

1K+ Views

To traverse through a HashMap, use Iterator. The HashMap class uses a hashtable to implement the Map interface. This allows the execution time of basic operations, such as get( ) and put( ), to remain constant even for large sets.Following is the code to traverse through a HashMap −Exampleimport java.util.*; ... Read More

The new operator in Java

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 11:23:09

5K+ Views

The new operator is used in Java to create new objects. It can also be used to create an array object.Let us first see the steps when creating an object from a class −Declaration − A variable declaration with a variable name with an object type.Instantiation − The 'new' keyword ... Read More

HTML DOM Textarea name Property

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 11:18:43

61 Views

The HTML DOM Textarea defaultValue property returns and modify the value of name attribute of a text area element in an HTML document.SyntaxFollowing is the syntax −1. Returning nameobject.name2. Adding nameobject.name = “text”Let us see an example of HTML DOM Textarea name Property:Example    body {     ... Read More

Nested Classes in Java

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 11:09:52

1K+ Views

Writing a class within another is allowed in Java. The class written within is called the nested class, and the class that holds the inner class is called the outer class. Nested classes are divided into two types −Non-static nested classes (Inner Classes) − These are the non-static members of a class.Static ... Read More

Java Integer compareUnsigned() method

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 11:06:25

175 Views

The compareUnsigned() method compares two integer objects numerically considering the values as unsigned.The return value if 0 if both values are equal; -1 if the val1is less than val2. The return value is 1, if the val1 is more than val2.At first, set two Integer objects −int val1 = 50; ... Read More

Java Integer compareTo() method

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 11:05:01

7K+ Views

The java.lang.Integer.compareTo() method compares two Integer objects numerically. This method returns the value 0 if this Integer is equal to the argument Integer, a value less than 0 if this Integer is numerically less than the argument Integer and a value greater than 0 if this Integer is numerically greater than the ... Read More

Java Integer compare() method

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 11:03:00

580 Views

The compare() method is used to compare two integer values numerically. The syntax is −int compare(int val1, int val2)  Above, a and b are the two integer values to be compared. If the return value is -1, therefore val1 is less than val2. Return value is 1, when val1 == ... Read More

Java Integer byteValue() method

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 11:01:11

158 Views

The byteValue() method returns the value of this Integer as a byte.Following is an example to implement the byteValue() method in Java −Examplepublic class Main {    public static void main(String[] args) {       Integer val = new Integer(10);       byte res = val.byteValue();     ... Read More

Advertisements