Java program to remove // a particular character // from a string. with out function code example

Example 1: delete ending part of the string java

//To delete starting from "opened"
String str ="13 opened by someone";

String result = str.substring(0,str.lastIndexOf(" opened"));

Example 2: how to remove letters from string java

public extractLetters(String str){
	String result="";
	for(int i= 0; i< str.length; i++){
	    if(Character.isLetter(str.charAt(i))){
	    result+=str.charAt(i);
	  	}
	}

Tags:

Java Example