How to split a Java String into tokens with StringTokenizer?

Abhinanda Shri
Updated on 11-Mar-2026 23:14:18

568 Views

The hasMoreTokens() method is used to test if there are more tokens available from this tokenizer's string.Exampleimport java.util.*; public class StringTokenizerDemo {    public static void main(String[] args) {       // creating string tokenizer       StringTokenizer st = new StringTokenizer("Come to learn");       // checking elements       while (st.hasMoreElements()) {          System.out.println("Next element : " + st.nextElement());       }    } }OutputNext element : Come Next element : to Next element : learn

Bootstrap btn-group-vertical class

Nancy Den
Updated on 11-Mar-2026 23:14:18

248 Views

The btn-group-vertical class make a set of buttons appear vertically stacked rather than horizontally.You can try to run the following code to implement btn-group-vertical class:Example           Bootstrap Example                                          BCA          B.Tech                                      Masters                                                        MCA                MBA                M.Tech                M.COM                                

How to check if a String contains another String in a case insensitive manner in Java?

Alankritha Ammu
Updated on 11-Mar-2026 23:14:18

2K+ Views

One way to do it to convert both strings to lower or upper case using toLowerCase() or toUpperCase() methods and test.Examplepublic class Sample {    public static void main(String args[]){       String str = "Hello how are you welcome to Tutorialspoint";       String test = "tutorialspoint";       Boolean bool = str.toLowerCase().contains(test.toLowerCase());       System.out.println(bool);    } }Outputtrue

Bootstrap Collapsible in

George John
Updated on 11-Mar-2026 23:14:18

305 Views

The collapsible in class in Bootstrap is used to display the collapsible content.You can try to run the following code to implement the collapsible in class −Example           Bootstrap Example                                          Quiz          Click below to toggle the button content.          More Quizzes                       We have quizzes on Java, PHP, Ruby, Quantitative Aptitude, ASP.net, etc.                    

bg-light class for Bootstrap 4 cards

Ricky Barnes
Updated on 11-Mar-2026 23:14:18

508 Views

To set a light grey background for the Bootstrap 4 cards, use the bg-light class.Use “card bg-light” like any other class in Bootstrap −   Image Editor The above gives a light grey background to the Bootstrap card.Let us see an example of the card-light class −Example       Bootstrap Example                             Web Tools           Image Editor             Image Optimizer      

Write a java program to tOGGLE each word in string?

Alankritha Ammu
Updated on 11-Mar-2026 23:14:18

1K+ Views

You can change the cases of the letters of a word using toUpperCase() and toLowerCase() methods.Split each word in the string using the split() method, change the first letter of each word to lower case and remaining letters to upper case.Examplepublic class Sample{    public static void main(String args[]){       String sample = "Hello How are you";       String[] words = sample.split(" ");       String result = "";       for(String word:words){          String firstSub = word.substring(0, 1);          String secondSub = word.substring(1);          result = result+firstSub.toLowerCase()+secondSub.toUpperCase()+" ";       }       System.out.println(result);    } }OutputhELLO hOW aRE yOU

Check if a string contains a number using Java.

Anjana
Updated on 11-Mar-2026 23:14:18

42K+ Views

To find whether a given string contains a number, convert it to a character array and find whether each character in the array is a digit using the isDigit() method of the Character class.Examplepublic class ContainsExample {    public static void main(String args[]){       String sample = "krishna64";       char[] chars = sample.toCharArray();       StringBuilder sb = new StringBuilder();       for(char c : chars){          if(Character.isDigit(c)){             sb.append(c);          }       }       System.out.println(sb);    } }Output64

Usage of Bootstrap navbar-form class

karthikeya Boyini
Updated on 11-Mar-2026 23:14:18

295 Views

To create navbar in CSS, use the navbar-form classExample           Bootstrap Example                                                       My Website                                                                                                  Submit                                

Find the 3rd smallest number in a Java array.

Kumar Varma
Updated on 11-Mar-2026 23:14:18

5K+ Views

ExampleFollowing is the required program.public class Tester {    public static int getThirdSmallest(int[] a) {       int temp;       //sort the array       for (int i = 0; i < a.length; i++) {          for (int j = i + 1; j < a.length; j++) {             if (a[i] > a[j]) {                temp = a[i];                a[i] = a[j];                a[j] = temp;             }          }       }       //return third smallest element       return a[2];    }    public static void main(String args[]) {       int a[] = { 11,10,4, 15, 16, 13, 2 };       System.out.println("Third Smallest: " +getThirdSmallest(a));    } }OutputThird smallest: 10

Bootstrap 4 .justify-content-*-end class

Amit Diwan
Updated on 11-Mar-2026 23:14:18

719 Views

To justify the flex items on the end, use the justify-content-end class.To justify the flex items on the end, on different screen sizes, use the justify-content-*-end class. The flex items justified at the end would be visible like the following on different screen sizes −Small Screen Size   Alabama   New York   Texas Medium Screen Size   Alabama   New York   Texas Let us see the complete code and learn how to work with justify-content-*-end class −Example       Bootstrap Example                               US               Alabama         New York         Texas                     Alabama         New York         Texas                     Alabama         New York         Texas        

Advertisements