6 more to go..... up! up! up! up!
20 is solve.. tnx javaP
update 1.2
11-14-17-22-23-24
6 more to go..... up! up! up! up!
20 is solve.. tnx javaP
update 1.2
11-14-17-22-23-24
String.length() raman ang function diha.
Kalimot nako sa java pero i think sa kani na line:
kay ga declare na siya ug char type array named chr_array with size s.length()Code:char [] chr_array = new char[s.length()];
Code:/* * 22. Write a Java class called DestroyAllOccurrences, which defines a main() method that asks the user to enter * two Strings superString and subString, and displays a new String consisting of all characters in superString * with all occurrences of subString deleted. You MUST NOT use any of the methods defined in the String class * other than charAt() and length(). */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author javapenguin */ public class DestroyAllOccurrences { public static void main(String[] args) { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String superString = new String(); String subString = new String(); System.out.println("Please enter a super string: "); try { superString = input.readLine(); } catch (IOException ex) { System.err.println(ex); } System.out.println("Please enter a sub string: "); try { subString = input.readLine(); } catch (IOException ex) { System.err.println(ex); } String newString = ""; boolean found = true; for (int i = 0; i < superString.length(); i++) { found = false; for (int j = 0; j < subString.length(); j++) { if (superString.charAt(i) == subString.charAt(j)) found = true; } if (!found) { newString = newString+superString.charAt(i); } } System.out.println("New String > "+newString); } }
Similar Threads |
|