what I'm trying to do is write a method that has one argument and returns a new string that capitalises that string and returns in its parameter.
this is my code so far:
public void input(){
this.printmessage("Dillon", "Francis", "chimes", "chimes from hudson mohawke", "2", "$69.00", "$420.00", "$1337.00");
}
public void printmessage(String firstName, String lastname, String product, String company, String number, String retail, String price, String saving){
UI.println("text " + firstName + ",");
UI.println(text + " " + product + "s text, text text text text -");
UI.println(" ");
}
What I want to do is capitalise the product parameter (chimes) and then return into into the printMessage capitalized if it is used at the beginning of a sentence.
Will something like this work?
public String capitalise(String product){
return Character.toUpperCase(product.charAt(0)) + product.substring(1);
}
I'm really stuck and would love some help.
Thanks.
I've tried this
String pls = (product + " example");
if ( pls.startsWith(product) ) {
product = capitalise(product);
}
UI.println(pls);
but it doesnt print out the capitalised version.