HTML DOM Table rows Collection

AmitDiwan
Updated on 20-Sep-2019 08:55:43

259 Views

The HTML DOM table rows Collection returns a collection of all elements of a table in an HTML document.SyntaxFollowing is the syntax −object.rowsProperties of rows Collectionelements in the collection in an HTML document.PropertyExplanationlengthIt returns the number of elements in the collection in an HTML document.Methods of rows Collectionelement from the collection element from the collection. element from the collectionMethodExplanation[index]It returns the specified index element from the collection.item(index) It returns the specified index element from the collection.namedItem(id)It returns the specified id element from the collectionLet us see an example of HTML DOM table rows Collection −Example Live ... Read More

HTML DOM Table deleteRow() Method

AmitDiwan
Updated on 20-Sep-2019 08:44:25

66 Views

The HTML DOM table deleteRow() method deletes a element from the table in an HTML document.SyntaxFollowing is the syntax −object.deleteRow(index)Here, index represent a number that specifies the position of the row to delete.Let us see an example of HTML DOM table deleteRow() method −Example Live Demo    body {       color: #000;       background: lightblue;       height: 100vh;       text-align: center;    }    table {       margin: 2rem auto;    }    .btn {       background: #db133a;       border: none;       ... Read More

HTML DOM Table deleteTHead() Method

AmitDiwan
Updated on 20-Sep-2019 08:40:50

44 Views

The HTML DOM table deleteTHead() method delete the element from the table in an HTML document.SyntaxFollowing is the syntax −object.deleteTHead()Let us see an example of HTML DOM table deleteTHead() method −Example Live Demo    body {       color: #000;       background: lightblue;       height: 100vh;       text-align: center;    }    table {       margin: 2rem auto;    }    caption {       color: #db133a;    }    .btn {       background: #db133a;       border: none;       height: 2rem;   ... Read More

Program for Celsius To Fahrenheit conversion in C++

Sunidhi Bansal
Updated on 20-Sep-2019 08:30:20

567 Views

Given with temperature ‘n’ in Celsius the challenge is to convert the given temperature to Fahrenheit and display it.ExampleInput 1-: 100.00    Output -: 212.00 Input 2-: -40    Output-: -40For converting the temperature from Celsius to Fahrenheit there is a formula which is given belowT(°F) = T(°C) × 9/5 + 32Where, T(°C) is temperature in Celsius and T(°F) is temperature in FahrenheitApproach used below is as followsInput temperature in a float variable let’s say CelsiusApply the formula to convert the temperature into FahrenheitPrint FahrenheitALGORITHMStart Step 1 -> Declare a function to convert Celsius to Fahrenheit    void cal(float cel) ... Read More

Check if a string contains only alphabets in Java using ASCII values

AmitDiwan
Updated on 20-Sep-2019 08:29:26

372 Views

Let’s say we have set out inut string in myStr variable. Now loop through until the length of string and check for alphabets with ASCII values −for (int i = 0; i < myStr.length(); i++) {    char c = myStr.charAt(i);    if (!(c >= 'A' && c = 'a' && c = 'A' && c = 'a' && c

Check if a string contains only alphabets in Java using Regex

AmitDiwan
Updated on 20-Sep-2019 08:24:32

800 Views

At first, convert the string into character array. Here, name is our string −char[] ch = name.toCharArray();Now, loop through and find whether the string contains only alphabets or not. Here, we are checking for not equal to a letter for every character in the string −for (char c : ch) {    if(!Character.isLetter(c)) {       return false;    }Following is an example to check if a string contains only alphabets using RegexExample Live Demopublic class Main {    public static boolean checkAlphabet(String name) {       char[] ch = name.toCharArray();       for (char c : ch) { ... Read More

Check if a string contains only alphabets in Java using Lambda expression

AmitDiwan
Updated on 20-Sep-2019 08:19:04

565 Views

Let’s say our string is −String str = "Amit123";Now, using allMatch() method, get the boolean result whether the string has only alphabets or now −boolean result = str.chars().allMatch(Character::isLetter);Following is an example to check if a string contains only alphabets using Lambda Expressions −Exampleclass Main {    public static void main(String[] args) {       String str = "Amit123";       boolean result = str.chars().allMatch(Character::isLetter);       System.out.println("String contains only alphabets? = "+result);    } }OutputLet us see another example with a different input −String contains only alphabets? = falseExampleclass Main {    public static void main(String[] args) ... Read More

Insert a String into another String in Java

AmitDiwan
Updated on 20-Sep-2019 08:16:38

2K+ Views

Let’s say we have a string “That’s good!” and within that we need to insert the text “no”. Therefore, the resultant string should be “That’s no good!” −String str = "That's good!"; String newSub = "no ";Now, the index where the new sub string will get inserted −int index = 6;Insert the new substring now −StringBuffer resString = new StringBuffer(str); resString.insert(index + 1, newSub);Let us now see an example to insert a string into another −Example Live Demoimport java.lang.*; public class Main {    public static void main(String[] args) {       String str = "That's good!";       ... Read More

Product of the nodes of a Singly Linked List

Sunidhi Bansal
Updated on 20-Sep-2019 08:01:06

256 Views

Given with n nodes the task is to print the product of all the nodes of a singly linked list. The program must traverse all the nodes of a singly linked list starting from the initial node till the NULL is not found.ExampleInput -: 1 2 3 4 5 Output -: 120In the above example, starting from first node all the nodes are traversed i.e 1, 2 3, 4, 5, 6 and their product is 1*2*3*4*5*6 = 120Approach used below is as followsTake a temporary pointer, lets say, temp of type nodeSet this temp pointer to first node which is ... Read More

Initialize HashMap in Java

AmitDiwan
Updated on 20-Sep-2019 07:57:58

501 Views

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 list of constructors supported by the HashMap class.Sr.NoConstructor & Description1HashMap( )This constructor constructs a default HashMap.2HashMap(Map m)This constructor initializes the hash map by using the elements of the given Map object m.3HashMap(int capacity)This constructor initializes the capacity of the hash map to the given integer value, capacity.4HashMap(int capacity, float fillRatio)This constructor initializes both the capacity and fill ratio of the hash map by using its ... Read More

Advertisements