Im just a beginner but I find java exciting
can someone help me Im trying to write a program
to spell ambulance backwards I think im close but
I need somw help Im using strings to spell.
Ty. :sad:

public class Ambulance {
public static void main(String[] arg) { /*
String s1 = "E"; *
String s2 = "C"; *
String s3 = "N"; * This will spell Ambulance backwards
String s4 = "A"; * We HOPE
String s5 = "L"; *
String s6 = "U"; *
String s7 = "B"; *
String s8 = "M"; *
String s9 = "A"; */
System.out.println();
System.out.println("AMBULANCE = ECNALUBMA");

This is what ive done so far I can compile and no errors found but i execute and nothing happens... TY for your help but please I want to do the work.

Greetings.
Umm...I guess what you want would be something like this:

public class Ambulance {
  public static void main(String[] arg) {
    String foo;
    char[] chr;

    foo = "Ambulance";
    chr = foo.toCharArray();    

    for(int i=foo.length()-1; i>=0; i--)
      System.out.print(chr[i]);
    
  }
}

However, to increase usability, I suggest that you code lines that prompts a string from the user.

ty for all of your help Ill try that and see what happens...

I know it's been forever since anyone's said anything on this topic, but how do you prompt a string from the user ... ???

And is this java or javascript?

I think you cross posting, but if you want to get input from user in java, there are many way to do it. If you use new java compiler, you can use Scanner class, like:

Scanner scan = new Scanner (System.in);
String userPromt = scan.nextLine();

if you want to get user promt using java script:

prompt('Prompt text to the user','Suggest input for the user to enter')
This article has been dead for over six months. Start a new discussion instead.