The Artima Developer Community
Sponsored Link

Java Buzz Forum
Biggest Substring in between specified character or String

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
instanceof java

Posts: 576
Nickname: instanceof
Registered: Jan, 2015

instanceof java is a java related one.
Biggest Substring in between specified character or String Posted: Feb 9, 2016 1:14 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by instanceof java.
Original Post: Biggest Substring in between specified character or String
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Latest Java Buzz Posts
Latest Java Buzz Posts by instanceof java
Latest Posts From Instance Of Java

Advertisement

1. Java Program to find biggest substring in between specified character or string

String: i am rajesh kumar ravi

in between: 'a'

 

  1. package com.instaceofjava;
  2.  
  3. public class BiggestSubString{
  4.  
  5. public static void main(String[] args) {
  6.  
  7. String str="i am rajesh kumar ravi";
  8.  
  9.  String longest="";
  10.  int maxlength=0;
  11.  
  12.  String arr[]=str.split("a");
  13.  
  14. for (int i = 1; i < arr.length-1; i++) {
  15.  
  16.    System.out.println(arr[i]); // printing substrings
  17.  
  18.           if(arr[i].length() > maxlength){
  19.                maxlength = arr[i].length();
  20.                 longest = arr[i];
  21.             }   
  22.  
  23.    }      
  24.   
  25. System.out.println("Longest substring is: "+longest);
  26.  
  27. }
  28. }


Output:

  1. m r
  2. jesh kum
  3. r r
  4. Longest substring is: jesh kum

Read: Biggest Substring in between specified character or String

Topic: Delete nodes from a Tree in Java Previous Topic   Next Topic Topic: Lean, Mean, Java Virtual Machine: Making Your Docker 7x Lighter With Alpine Linux

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use