Jimbo99999
asked on
Java Code Translation
Good Day Experts
I am relatively new to Java...the programming is getting better. However, I am still thin on the terminology to explain the code. Here are some lines of code that I am using but am curious how they "translate". UserInput is my LinkedList. Can someone reply with the proper way to say what each of these lines of code are?
import java.util.LinkedList;
String[] UserInputTokens = UserInput.split(delims);
for (String t : UserInputTokens ){
//process
}
Thanks,
jimbo99999
I am relatively new to Java...the programming is getting better. However, I am still thin on the terminology to explain the code. Here are some lines of code that I am using but am curious how they "translate". UserInput is my LinkedList. Can someone reply with the proper way to say what each of these lines of code are?
import java.util.LinkedList;
String[] UserInputTokens = UserInput.split(delims);
for (String t : UserInputTokens ){
//process
}
Thanks,
jimbo99999
ASKER
Thanks sounds good...
One last inquiry about the line --> String[] UserInputTokens = UserInput.split(delims);
How do you say what the [] are after String?
Thanks,
jimbo99999
One last inquiry about the line --> String[] UserInputTokens = UserInput.split(delims);
How do you say what the [] are after String?
Thanks,
jimbo99999
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In Java, I guess as opposed to C and some other languages, you can
declare arrays with the array specification after the variable, as well as
before the variable - between the variable and the type.
You can either declare:
String myStrings[];
or you can say
String [] myStrings;
At first this latter method looks odd when you come from other
languages, but it is probably even more popular in Java programs
than the former way
ASKER
Thanks...I forgot one. Promise the last one.
When I add the token to my LinkedList i do --> UserInputList.add(x)
How do I explain that in English? I know this is bad that I use it and cannot describe but I am learning.
Thanks,
jimbo99999
When I add the token to my LinkedList i do --> UserInputList.add(x)
How do I explain that in English? I know this is bad that I use it and cannot describe but I am learning.
Thanks,
jimbo99999
What is it you wnat to explain?
You just add one more lement to the collection
You just add one more lement to the collection
What is it you want to explain?
You just add one more element to the collection, as your linked list is one of the variants of a collection
ASKER
UserInputList.add(x)
Do you say execute .add method on UserInputList ?
Do you say execute .add method on UserInputList ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to everyone who replied. All your contributions help out a lot.
Thanks again,
jimbo99999
Thanks again,
jimbo99999
tell the compiler what class you will be using
String[] UserInputTokens = UserInput.split(delims);
split the UserInput string on the delim delimiter
for (String t : UserInputTokens ){
//process
}
Loop processing each of the tokens returned from splitting the UserInput string