且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将void返回类型clear函数转换为字符串返回类型。

更新时间:2022-03-01 22:58:23

public static String Clear(String s)
	{
		String sReturn = "";
		String wo[]=s.split(" ");
	       for(String w:wo)
	      {
	    	  return w; // Maybe you need a lineSpace
	      }
	       sReturn = "clear words i.e. after ignoring special characters and no. and converting all to small letters are:";
	      	
	      String word;
	       for(int i=0;i<wo.length;i++)
	       { 
	    	   word=wo[i].toLowerCase();
	    	    List<Character> li=new ArrayList<Character>(); 
	    	    for (char ch:word.toCharArray())
	    	      if(ch>='a' && ch<='z')
	    	      li.add(ch);
	    	    String ss="";
	    	    for(char ch:li)
	    	    ss=ss+ch;
	    	    
	    	    sReturn += ss; // Maybe you need a lineSpace
	      }

	      return sReturn;
	}