Converting a sentence into an array and editing the first letter of each value within the array

ساخت وبلاگ

Vote count: 0

I have searched alot for the code for this and have found a lot of information but not really what I am looking for. I have am working on a program that accepts a sentence input from a user, takes all the words from that input and places them into an array. From there I need to edit the first character of every word and then move it to the last letter of the word. From there I then need to output the array back into a single sentence string with all the spaces in place. I am doing this using an instantiable class.

My code so far:

 public class Language2{ //Variables private String input; private char firstLetter; private String output; //Constructor public Language2(){ input = " "; output = " "; } //Set Method public void setLanguage2 (String input){ this.input = input; } //Compute public void compute(){ String [] wordCount = input.split(" "); for (int i = -1; i < wordCount.length; i++);{ char firstLetter = wordCount[i].charAt(0); wordCount[i] = wordCount[i].substring(1); wordCount[i] = wordCount[i] + firstLetter + "ay"; } output = String.join(" ", wordCount); } //Get Method public String getOutput(){ return output; } }

Please note that I'm not sure of all of this code as to whether it's best for the job or even wholly right. I'm only learning java and trying to understand what it is I have to do as well as do it. For example, the "wordCount[i].charAt(0)" throws back an error trying to interpret what i is, so I'm assuming that I am using it wrong in this case.

Any and all help is greatly appreciated, thank you.

Neo

asked 6 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 295 تاريخ : سه شنبه 19 ارديبهشت 1396 ساعت: 1:00

خبرنامه