To do so, Trim the given string and split it using the split() method (Removing the empty spaces in-between).Create an integer array and in loop convert each element of the string array to an integer using Integer.parseInt() method and assign it to the respective element of the integer array.Sort the obtained integer array, since this method sorts the elements of the array in ascending order the last element will be the maximum of the array. Create an integer variable count with initial value 0. Compare each element of the array with the maximum value, each time a match occurs increment the count. The final value ... Read More
Use the bg-primary class in Bootstrap 4, to add important stuff to a card and set blue background color.Style the Bootstrap 4 card as in the following code snippet − Medical Books I have set the body of the card in the card-body class − Medical Books To implement the bg-primary class in Bootstarp 4, you can try to run the following code −ExampleLive Demo Bootstrap Example Books History Books Medical Books
You can use write data into a file using the Writer classes. In the example given below, we are writing the contents of the array using the BufferedWriter.ExampleLive Demoimport java.io.BufferedWriter; import java.io.FileWriter; public class WritingStringArrayToFile { public static void main(String args[]) throws Exception { String[] myArray = {"JavaFX", "HBase", "OpenCV", "Java", "Hadoop", "Neo4j"}; BufferedWriter writer = new BufferedWriter(new FileWriter("myFile.txt", false)); for(int i = 0; i < myArray.length; i++) { writer.write(myArray[i].toString()); writer.newLine(); } writer.flush(); ... Read More
The shown.bs.tooltip event in Bootstrap fires when the tooltip is completely displayed:$("[data-toggle='tooltip']").on('shown.bs.tooltip', function(){ alert('Tooltip is completely visible now.'); });The data-toggle attribute above is set on a link, wherein the popup will originate on button click as shown in the following code snippet: Timings You can try to run the following code to implement the shown.bs.tooltip event −ExampleLive Demo Bootstrap Example Event Here tooltip will be displayed using the ... Read More
Use the border-danger class to set a red border to an element.Set the border-danger class to an element as if we include any other class − Red Border Above, we have also set another class “new”, to style the element − .new { width: 120px; height: 120px; margin: 20px; } You can try to run the following code to implement the border-danger class −ExampleLive Demo Bootstrap Example .new { width: 120px; height: 120px; margin: 20px; } Rectangle with red border: Red Border
To make an array iterable either you need to convert it to a stream or as a list using the asList() or stream() methods respectively. Then you can get an iterator for these objects using the iterator() method.ExampleLive Demoimport java.util.Arrays; import java.util.Iterator; public class ArrayToIterable { public static void main(String args[]){ Integer[] myArray = {897, 56, 78, 90, 12, 123, 75}; Iterator iterator = Arrays.stream(myArray).iterator(); while(iterator.hasNext()) { System.out.println(iterator.next()); } } }Output897 56 78 90 12 123 75As mentioned above, you can also convert ... Read More
You can read the contents of a file using the Scanner class and You can find the comments in a particular line using contains() method.Exampleimport java.io.*; import java.util.Scanner; public class FindingComments { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(new File("HelloWorld")); String input; int single = 0; int multiLine = 0; while (sc.hasNextLine()) { input = sc.nextLine(); if (input.contains("/*")) { multiLine ++; ... Read More
To create a block on a specific screen width, use the .d-*-block class.The specific screen width can be small, medium, large and extra large. Set the class indivifually based on the screen size as shown below − d-sm-block d-md-block d-lg-block< /span> d-xl-block Let us see the complete example to learn how to create a block element on a specific screen width −ExampleLive Demo Bootstrap Example Blocks Resize the browser to check the effect d-block d-sm-block d-md-block d-lg-block d-xl-block
Java supports inheritance, an OOPs concept where one class acquires the members (methods and fields) of another.You can inherit the members of one class from another, use the extends keyword as:class A extends B{}The class which inherits the properties of other is known as child class (derived class, sub class) and the class whose properties are inherited is known as parent class (base class, superclass class).Following is an example which demonstrates inheritance. Here, we have two classes namely Sample and MyClass. Where Sample is the parent class and the class named MyClass is the child class.ExampleLive Democlass Sample{ public ... Read More
Use the d-flex class in Bootstrap to create a flexbox container.Here, I have set two flex items − One Two Above, I have used the d-flex class to set the container. The container has both the flex items styled using the bg-primary and bg-warning classes respectively.Let us see the complete example −ExampleLive Demo Bootstrap Example Understanding Flex One Two
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP