Suppose that you have a String named p Write a line of code
Suppose that you have a String named p. Write a line of code that will define an int variable called y and set the value of y to the length of p. I am using java.
Solution
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be \"Main\" only if the class is public. */
class Expert
{
public static void main (String[] args) throws java.lang.Exception
{
String p=\"Hello Dear!\";
int y;
y=p.length();
System.out.println(\"The length of the string is=\"+y);
}
}
Below is given the line of code which is doing the job.
int y;
y=p.length();
if you like this answer, please give a thumbs up and if you have some doubt just ask in the comment section below. I will try to help. Cheers
