Click here to Skip to main content
15,887,683 members
Home / Discussions / Java
   

Java

 
SuggestionRe: room allocation and optimisation Pin
Richard Deeming14-Apr-14 9:00
mveRichard Deeming14-Apr-14 9:00 
AnswerRe: room allocation and optimisation Pin
Bernhard Hiller14-Apr-14 22:52
Bernhard Hiller14-Apr-14 22:52 
Questionchat application Pin
nik-123414-Apr-14 7:15
nik-123414-Apr-14 7:15 
AnswerRe: chat application Pin
Richard MacCutchan14-Apr-14 21:52
mveRichard MacCutchan14-Apr-14 21:52 
AnswerRe: chat application Pin
mkumar_mtech15-Apr-14 1:57
professionalmkumar_mtech15-Apr-14 1:57 
Questionhow to apply horizental scroll bar in jsf Pin
sunil khichar11-Apr-14 7:26
sunil khichar11-Apr-14 7:26 
AnswerRe: how to apply horizental scroll bar in jsf Pin
Richard MacCutchan11-Apr-14 7:45
mveRichard MacCutchan11-Apr-14 7:45 
QuestionString Reverse Pin
V$ethi5-Apr-14 3:27
V$ethi5-Apr-14 3:27 
Hi , I am just trying to reverse all the words of a string at their place only ex if there is a string : "vandana is a good girl" then the out put of the program should be "anadnav is a doog lrig" for that i have created a package to calculate the no of words in the string and also for calculating reverse of a string that pacage is:
package p1;
public class meth
{
public int cal(String s)
{
int wrd=0;
for(int i=0;i<s.length();i++)
{
char c=s.charAt(i);
if(Character.isWhitespace(c))
{
wrd++;
}
}
return wrd+1;
}
public String rev(String b)
{
String p="";
for(int i=0;i<b.length();i++)
{
p=b.charAt(i)+p;
}
return p;
}
}
-----------------------------------------------------------------And the code of my program is :
import p1.*;
import java.io.*;
class rv
{
public static void main(String args[]) throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.println("Enter your string :");
String s=br.readLine();
meth ob=new meth();
int n=ob.cal(s);
String m="";
while(n>=0)
{
for(int i=0;i<s.lenght();i++)
{
char c=s.charAt(i);
if(Character.isWhitespace(c))
{
String p=s.substring(0,i);
meth ob1=new meth();
String sb=ob1.rev(p);
m=m+" "+sb;
s=s.substring(i+1,s.length());
}
}
n--;
}
System.out.println(m);
}
}
but the problem is my program gives different different out put and it's not working well and i've tired Sleepy | :zzz: to understand th problem.

-- modified 5-Apr-14 14:25pm.
AnswerRe: String Reverse Pin
Richard MacCutchan5-Apr-14 3:47
mveRichard MacCutchan5-Apr-14 3:47 
GeneralRe: String Reverse Pin
V$ethi5-Apr-14 6:24
V$ethi5-Apr-14 6:24 
GeneralRe: String Reverse Pin
Richard MacCutchan5-Apr-14 6:47
mveRichard MacCutchan5-Apr-14 6:47 
GeneralRe: String Reverse Pin
V$ethi5-Apr-14 8:21
V$ethi5-Apr-14 8:21 
GeneralRe: String Reverse Pin
Richard MacCutchan5-Apr-14 21:29
mveRichard MacCutchan5-Apr-14 21:29 
GeneralRe: String Reverse Pin
Richard MacCutchan5-Apr-14 6:49
mveRichard MacCutchan5-Apr-14 6:49 
AnswerRe: String Reverse Pin
vipul57413-Jun-14 3:08
vipul57413-Jun-14 3:08 
Questionjava code i need Pin
Member 107262375-Apr-14 1:33
Member 107262375-Apr-14 1:33 
AnswerRe: java code i need Pin
Member 107262375-Apr-14 1:45
Member 107262375-Apr-14 1:45 
GeneralRe: java code i need Pin
Richard MacCutchan5-Apr-14 1:48
mveRichard MacCutchan5-Apr-14 1:48 
Questionget a certain String from .txt file Pin
mtouxx3-Apr-14 21:11
mtouxx3-Apr-14 21:11 
AnswerRe: get a certain String from .txt file Pin
Richard MacCutchan3-Apr-14 22:12
mveRichard MacCutchan3-Apr-14 22:12 
GeneralRe: get a certain String from .txt file Pin
mtouxx15-Apr-14 8:24
mtouxx15-Apr-14 8:24 
GeneralRe: get a certain String from .txt file Pin
Richard MacCutchan15-Apr-14 10:03
mveRichard MacCutchan15-Apr-14 10:03 
GeneralRe: get a certain String from .txt file Pin
mtouxx15-Apr-14 20:05
mtouxx15-Apr-14 20:05 
GeneralRe: get a certain String from .txt file Pin
Richard MacCutchan15-Apr-14 22:18
mveRichard MacCutchan15-Apr-14 22:18 
GeneralRe: get a certain String from .txt file Pin
mtouxx15-Apr-14 22:51
mtouxx15-Apr-14 22:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.