AmitDiwan has Published 11365 Articles

Java Integer bitCount() method

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 10:58:54

121 Views

The java.lang.Integer.bitCount() method returns the number of one-bits in the two's complement binary representation of the specified int value.At first, set an int value −int val = 210;Now, find the number of one-bits −Integer.bitCount(val)Following is an example to implement the bitCount() method in Java −Examplepublic class Main {    public static void ... Read More

Check if a value is present in an Array in Java

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 10:57:19

676 Views

At first sort the array −int intArr[] = {55, 20, 10, 60, 12, 90, 59}; // sorting array Arrays.sort(intArr);Now, set the value to be searched in an int variable −int searchVal = 12;Check for the presence of a value in an array −int retVal = Arrays.binarySearch(intArr, searchVal); boolean res = ... Read More

Check if a String starts with any of the given prefixes in Java

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 10:54:48

384 Views

Let’s say the string is −String str = "Malyalam";Let’s say the prefixes are in an array −String[] prefixArr = { "Ga", "Ma", "yalam" };Now, to check whether the string starts with any of the abive prefix, use the startsWith() −if (Stream.of(prefixArr)    .anyMatch(str::startsWith))    System.out.println("TRUE"); else    System.out.println("FALSE");Following is an ... Read More

HTML DOM TableHeader abbr Property

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 10:43:20

32 Views

The HTML DOM TableHeader abbr property returns and modify the value of abbr attribute of a table in an HTML document.SyntaxFollowing is the syntax −1. Returning abbrobject.abbr2. Adding abbrobject.abbr = “text”Let us see an example of abbr property:Example Live Demo    body {       color: #000;   ... Read More

HTML DOM TableRow Object

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 10:39:14

59 Views

The HTML DOM TableRow Object represent the element of an HTML document.Create TableRow objectSyntaxFollowing is the syntax −document.createElement(“TR”);Properties of TableRow objectPropertyExplanationrowIndexIt returns the position of a row in the rows collection of a table.sectionRowIndexIt returns the position of a row in the rows collection of a thead, tbody, or ... Read More

HTML DOM TableHeader Object

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 10:32:21

56 Views

The HTML DOM TableHeader Object represent the element of an HTML document.Create TableHeader objectSyntaxFollowing is the syntax −document.createElement(“TH”);Properties of TableHeader objectPropertyExplanationcellIndexIt returns the position of a cell in the cell collection of a table row.colSpanIt returns and alter the value of colspan attribute of a table.headersIt returns and alter ... Read More

HTML DOM TableData Object

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 10:25:05

70 Views

The HTML DOM TableData Object represent the element of an HTML document.Create TableData objectSyntaxFollowing is the syntax −document.createElement(“TD”);Properties of TableData objectPropertyExplanationcellIndexIt returns the position of a cell in the cell collection of a table row.colSpanIt returns and alter the value of colspan attribute of a table.headersIt returns and alter ... Read More

HTML DOM TableData rowSpan Property

AmitDiwan

AmitDiwan

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

159 Views

The HTML DOM TableData rowSpan property returns and modify the value of rowspan attribute of a table in an HTML document.SyntaxFollowing is the syntax −1. Returning rowSpanobject.rowSpan2. Adding rowSpanobject.rowSpan = “number”Let us see an example of rowSpan property −Example Live Demo    body {       color: #000; ... Read More

HTML DOM Table tHead Property

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 09:10:08

87 Views

The HTML DOM table tHead property returns the element of the table in an HTML document.SyntaxFollowing is the syntax −object.tHeadLet us see an example of HTML DOM table tHead property −Example Live Demo    body {       color: #000;       background: lightblue;     ... Read More

HTML DOM Table tFoot Property

AmitDiwan

AmitDiwan

Updated on 20-Sep-2019 09:06:28

61 Views

The HTML DOM table tFoot property returns the element of the table in an HTML document.SyntaxFollowing is the syntax −object.tFootLet us see an example of HTML DOM table tFoot property −Example Live Demo    body {       color: #000;       background: lightblue;     ... Read More

Advertisements