Question: public class penavalerytask 1 { public static void sentenceReverser ( String sentence ) { / / Declareing the result and initializing it String result =

public class penavalerytask1{
public static void sentenceReverser(String sentence){
// Declareing the result and initializing it
String result ="";
// Loop for characters in reverse order
for (int i = sentence.length()-1; i >=0; i--){
result += sentence.charAt(i);
}
// Printing the sentence in reverse
System.out.println(result);
}
public static void main (String[] args){
String str = "Valery Pena";
// Calls the method and passes the str variable
sentenceReverser(str);
}
} is this AI generated

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!