Bubble short assening order 5 9 8 -2 1 1st titration 4 comparison 2nd itteretion 3 comparison and so on comparison = n-i; public class BubbleSortExample { static void bubbleSort( int [] arr) { int n = arr.length; int temp = 0 ; for ( int i= 0 ; i < n; i++){ for ( int j= 1 ; j < (n-i); j++){ if (arr[j- 1 ] > arr[j]){...
// Java Program to Check Whether String contains Special // Characters Using Character Class // Importing input output classes import java.io.*; // Main class class GFG { // Method 1 // Main driver method public static void main(String[] args) { // Declaring and initializing count for // special characters int count = 0; // Input custom string String s = "!#$GeeeksforGeeks.Computer.Science.Portal!!"; // Iterating through the string // using standard length() method for (int i = 0; i < s.length(); i++) { // Checking the character for not being a // letter,digit or space if (!Character.isDigit(s.charAt(i)) && !Character.isLetter(s.charAt(i)) && !Character.isWhitespace(s.charAt(i))) { // Incrementing the countr for spl // characters by unity count++; } } // When there is no special character encounterd if (count == 0) // Display the print statement System.out.println...
Comments
Post a Comment