LearnString.java
This is the file that needs to be edited to finish the first part of assignment.
Size 1.5 kB - File type text/x-javaFile contents
/**
* Demonstrate capabilities of String class
* Use your knowledge of types and method
* to finish the lab. There are parts missing
* and errors as well. So i.e.think what do you
* need to add to have certain part of print
* statement to work and so on.
* Also, all of the answers can be tested via
* print statements. Only last one is finishing
* the expression.
*
* Lab9
*
*/
public class LearnString
{
public static void main (String args[]){
String m = "hello";
String q = m;
String s = new String("Demonstration");
String p = new String("hello");
String r = m+s;
//l gives the length of String m
//What is the needed expression print the following
//statment correctly?
System.out.println("length of m is: " +l);
//What does this do?
System.out.println("concat is: " r);
//What does this print and what index is the function using?
System.out.println("character is: " +s.charAt(6));
//Make String m all upper case
//What is the index of r for String s?
//What is difference between "==" and "equals"?
//m and p are same objects? How about m and q?
//Does m equal p? Does m equal s?
//if you have an integer and want to return string representation
//of the value, How will you do so?
int value = 9;
//Hint: finish the missing expression to answer the question
//Also remember how to use a static method.
//String valToStr =
System.out.println("value of valToStr is " +valToStr);
}
}
Click here to get the file