Object Oriented Programming Articles

Page 205 of 589

How to open a plain text file in Java?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 427 Views

You can access a plain text using the File class.Exampleimport java.io.File; public class ReadFile {    public static void main(String[] args) {       File f = null;       String str = "data.txt";       try {          f = new File(str);          boolean bool = f.canExecute();          String a = f.getAbsolutePath();          System.out.print(a);          System.out.println(" is executable: "+ bool);       } catch (Exception e) {          e.printStackTrace();       }    } }Output C:\Users\data is executable: true

Read More

How to find the vowels in a given string using Java?

Arushi
Arushi
Updated on 11-Mar-2026 39K+ Views

You can read a character in a String using the charAt() method. To find the vowels in a given String you need to compare every character in it with the vowel letters. Example public class FindingVowels {    public static void main(String args[]) {       String str = new String("Hi Welcome to Tutorialspoint");       for(int i=0; i

Read More

Count occurrences of a substring recursively in Java

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 9K+ Views

Given two strings str_1 and str_2. The goal is to count the number of occurrences of substring str2 in string str1 using a recursive process.A recursive function is the one which has its own call inside it’s definition.If str1 is “I know that you know that i know” str2=”know”Count of occurences is − 3Let us understand with examples.For ExampleInputstr1 = "TPisTPareTPamTP", str2 = "TP";OutputCount of occurrences of a substring recursively are: 4ExplanationThe substring TP occurs 4 times in str1.Inputstr1 = "HiHOwAReyouHiHi" str2 = "Hi"OutputCount of occurrences of a substring recursively are: 3ExplanationThe substring Hi occurs 3 times in str1.Approach used ...

Read More

Change input type value attribute in jQuery

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 5K+ Views

Let’s say the following is our input type with value, “John Smith” −To change, use the attr() method −$('#changeTheName').attr('value', 'Please enter your name.......');You need to use the concept of attr(). Following is the code −Example Document    $('#changeTheName').attr('value', 'Please enter your name.......'); To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.OutputThis will produce the following output −

Read More

How to hide table rows containing zero value with jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 2K+ Views

Let’s say the following is our table with product quantity records − qty: qty: qty: qty: Let us now hide using the hide() method. Following is the code −Example Document qty: qty: qty: qty:    $('.hideRowContainingZeroValue input').filter(function(){       return +this.value === 0;    }).closest("tr").hide() To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.OutputThis will produce the following output −

Read More

Fetch value from Alert pop up in jQuery

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 618 Views

To fetch value from alert pop up, use alert(). At first, use prompt() to input the value from user. Following is the code −Example Document    var value = prompt("Please enter an integer value");    var multiplyBy10=10*value;    alert("Result after multiplying by 10 = "+ multiplyBy10); To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor −OutputThis will produce the following output −Put an integer value and click the OK button.After clicking the OK button, the snapshot is as follows −

Read More

List View Search list on typing with filter like keyword search using jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 4K+ Views

Let’s the following is our input type, wherein the user will search −Now, use hide() and show() to display only relevant search and hide rest. For example, on typing “Ja”, related keywords like “Java” and “JavaScript” should be visible because it begins with “Ja”.Example Document Enter the keyword.. JavaScript John Smith Java David Miller -1) {             $(this).show();             $(this).prev('.subjectName').last().show();          } else {             $(this).hide();       ...

Read More

How to find the frequency of repeated and unique values in a vector in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Mar-2026 398 Views

If we unique values in a vector in R and they are repeated then we can find the frequency of those unique values, this will help us to understand the distribution of the values in the vector. On the basis of that distribution analysis, we can proceed with the further analysis that could be used. This can be done with the help of rle function.Examplex1

Read More

Store and retrieve arrays into and from HTML5 data attributes with jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 2K+ Views

To store and retrieve arrays into and from data attributes, use the data() method in jQuery. Following is the syntax −var anyVariableName= $('#yourIdName).data('yourJavscriptArrayName');Following is the jQuery code −Example Document    var value = $('#test').data('details');    alert(value); To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.OutputThis will produce the following output −

Read More

How to get value from the first checkbox which is not hidden in jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 904 Views

To get value from the first checkbox, which is not hidden, use the :visible selector. Following is the code −Example >Document    .notShown {       display: none; }    var v=$('input:checkbox:checked:visible:first').val();    console.log(v); To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.This will produce the following output displaying the visible value “second” in console −

Read More
Showing 2041–2050 of 5,881 articles
« Prev 1 203 204 205 206 207 589 Next »
Advertisements