Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Java the implements this function will return a copy of the original String that has all characters replaced with plus signs ("+"), with the exception of word string appearances, which are left alone.

public String plusOut(String str, String word) {
 int slen = str.length();
 int wlen = word.length();
 String fin = "";
  
 for (int i = 0; i < slen; i++) {
   if (i <= slen - wlen) {
     String tmp = str.substring(i,i+wlen);
     if (tmp.equals(word)) {
       fin += word;
       i += wlen-1;
     }
     else
       fin += "+";
   }
   else
     fin += "+";
 }
  
 return fin;
}
Comment

Java the implements this function will return a copy of the original String that has all characters replaced with plus signs ("+"), with the exception of word string appearances, which are left alone.

public String plusOut(String str, String word) {
 int slen = str.length();
 int wlen = word.length();
 String fin = "";
  
 for (int i = 0; i < slen; i++) {
   if (i <= slen - wlen) {
     String tmp = str.substring(i,i+wlen);
     if (tmp.equals(word)) {
       fin += word;
       i += wlen-1;
     }
     else
       fin += "+";
   }
   else
     fin += "+";
 }
  
 return fin;
}
Comment

PREVIOUS NEXT
Code Example
Java :: class generique java 
Java :: random years java 
Java :: produces 
Java :: convertBirthDay java 
Java :: all GlideException#logRootCauses(String) for more detail Cause (1 of 1): class javax.net.ssl.SSLPeerUnverifiedException: Hostname 
Java :: textbox to arraylist 
Java :: constructors in java 
Java :: how to clear scoreboard with offline players java 
Java :: concatenar java 
Java :: comparable interface 
Java :: draaiom 
Java :: quitar letras repetidas de una palabra en java 
Java :: 2 multiples recursion 
Java :: start/php2 
Java :: fill a 2d array java 
Java :: Change or Replace ArrayList Elements using set() function 
Java :: how to create an abstract class in java 
Java :: Rotate Left k cells java 
Java :: android studio null 
Java :: how to make factorial in java recursive 
Java :: how to declare and allocate memory to array in java 
Java :: java program for calendar using applet 
Java :: Determining what type of data the ArrayList will contain in java. 
Java :: fibonacci series 
Java :: int array to map java 
Java :: spring jpa group by query method 
Java :: math.round java 
Java :: java character in string 
Java :: how to get stack trace of a function in java 
Java :: java how to write something on the console with scanner 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =