TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Java

Get Substring of Given String in Java

Overview

In this tutorial, we will learn to extract or get substring of given String in a Java program.

Sample Code

Sample Java program to show the use of the substring() method.

/*******************************************
 * Java String substring() method Example
 * Java Tutorials - www.TestingDocs.com
 *
 ********************************************/
public class JavaSubStringExample {

 public static void main(String args[]) {
 String str= new String("www.TestingDocs.com 
Software Testing Website ");
 System.out.println("Substring upto index 20:");
 System.out.println(str.substring(0,20));
 System.out.println("Substring from
 index 20 and ending at 45:");
 System.out.println(str.substring(20, 45));
 } 
}

Related Posts

Download Greenfoot Windows

Java /

Download & Install Greenfoot on Windows

Java /

Java Static Code Analysis

Java /

Java Testing Tools

Java /

Handle Multiple Exceptions in Java

Exceptions_In_Java

Java /

Exceptions in Java Programs

‹ Java Interpreter› Types of Java Comments

Recent Posts

  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • RAPTOR Editions
  • Flowgorithm Conditional Breakpoint Statement
  • Flowgorithm Read Numbers from File Example
  • Search Text File Flowchart Example
  • Flowgorithm Turtle Graphics Symbols
  • Draw Circle using Flowgorithm Turtle
  • Draw Parallel Lines using Flowgorithm Graphics

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version