string length in java
String data = "Hello, World!";
int nameLength = data.length(); // 13public class Sample_String {
public static void main(String[] args) {
//declare the String as an object S1 S2
String S1 = "Hello Java String Method";
String S2 = "RockStar";
//length() method of String returns the length of a String S1.
int length = S1.length();
System.out.println("Length of a String is: " + length);
//8 Length of a String RockStar
System.out.println("Length of a String is: " + S2.length());
}
}
String data = "Hello, World!";
int nameLength = data.length();
Also in Java:
- vector in java
- check last character of string java
- java output length of each line in a text document
- arraylist with values java
- java find if element of list in present in another list
- hashmap in java
- java script print date in YYYY-MM-DD HH:MM:SS format
- java script to detect and launch all browsers
- java check if file exists
- how to create an abstract class in java
- stream java example
- countdown timer with seekbar
- make a commet in java
- arraylist remove method java
- android get last crash adb
- java create folder
- Error executing Maven. java.io.FileNotFoundException: The specified user settings file does not exist: /etc/java-8-openjdk
- count the number of words in a string java
- how to get a user input in java
- how to change the color of a menubar in java
- spring code in java
- java doreturn void
- java print syntax
- java create file