Java String Examples

Java String Length Example

Want to learn quickly?
Try one of the many quizzes. More than Java 400 questions with detailed answers.

Add Comment

  • hi i m new to java!!
    and one of our tasks to create a program to count the number of words in a string and the number of Characters in that string..
    can any one let me kw where i mistaken??
    i hv create the prog but it takes a dot as a chacater what to do??

    • public class Sum{
      public static void main(String args[]){
      int sumOfFirstFiveNumbers = 0;
      int temp = 1;
      while(temp <= 5){
      sum = sum + temp;

  • Write a program that prompts the user to input an integer and the output the number with the digits reversed. For example if the input is 12345, the output should be 54321

    • /*
      * To change this license header, choose License Headers in Project Properties.
      * To change this template file, choose Tools | Templates
      * and open the template in the editor.
      package mobileapplicationlicthomepractice.CoreJavaDay1Assignment;

      * @author Md.Asiful
      public class IntReverse {

      public int reverse(String original)

      int length=original.length();
      String reverse=””;
      for (int counter =length-1; counter>=0; counter–)

      int convertToInt=Integer.parseInt(reverse);
      return convertToInt;



Facebook Fans