Hi Everyone, In case you haven't guessed I'm working with command line arguments. I'm trying to have the user enter a word in the command line and the program tell the user if it is a palindrome or not. (Reminder: Palindrome is a word that is spelt the same forward and reverse ie) noon, mom, bob etc.) My text gives me the basics but the actual code is what I'm having problems with (obviously). I'm not sure I've stated my boolean method right. Again I'm new to all of this so some insight and explanation would help. I don't want to be told the code, I want to be given advise on what I need to be doing so I can figure it out my self. Below is what I have so far:
Thanks in advance Stacey
(Marilyn added code tags for better readability) [ February 11, 2004: Message edited by: Marilyn de Queiroz ]
Topno is right see your method definition of the isPalindrom, you havent specified that argument type in that definition. ~Loveen
Joined: Jan 11, 2004
I kinda get what you two are saying but the comand line argument (arg 0) is throwing me off. I really don't know where to go from here. I knew the code wouldn't compile and I realize because of the isPalindrome method but again I'm still lost. Stacey
args is just an array of strings. if you look at the signiature of main, it's public static void main (String  args). actually, "args" could really be any valid variable name - args, inputs, command_line_arguments... whatever. so when at the command prompt you type: c:\>java someProgram hello to you <enter> the 3 input parameters ("hello", "to", and "you") are now in the array at args, args, and args. I assume you know about arrays and how they are 0 indexed, right? your program tests to make sure the user input EXACTLY ONE argument at the if (args.length != 1) line. then, assuming the user DID input one argument (which would be stored in an array of size 1, with the string at args), you pass that string to your method to test for palindromity. Hope that made some sense, and answers your question.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joined: Nov 24, 2001
same question is posted in two headings (Command Line Arguments, Please Help )... me getting confused where to reply and where actually the author is looking for answer and so where to reply.