Question
Find and identify the error in each of the following code segments. No correction is needed just identify the error(s). 1. int number = 99;
Find and identify the error in each of the following code segments. No correction is needed just identify the error(s).
1. int number = 99; String str;
// Convert number to a string. str.valueOf(number);
2. // Store a name in a StringBuilder object. StringBuilder name = "Joe Schmoe";
3. int number; String str = "99";
// Convert str to an int. number = str.parseInt();
4. // Change the very first character of a // StringBuilder object to 'Z'. str.setCharAt(1, 'Z');
5. // Tokenize a string that is delimited // with semicolons. The string has three tokens. StringTokenizer strTokenizer = new StringTokenizer("One;Two;Three"); // Extract the three tokens from the string. while (strTokenizer.hasMoreTokens()) {
System.out.println(strTokenizer.nextToken());
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started