How to intercept the last few characters of a string in java:
To intercept the last few characters of a string in java, you can use the substring method of the String class, please refer to the instructions below for specific usage:
1. substring(int beginIndex)
substring(int beginIndex)
Returns a new string that is a substring of this string. Intercept
Intercept all characters starting from string position beginIndex-1 and later. Note that the starting position of the characters starts from 0.
Example:
String name="weicc-20100107-00001"; System.out.println(name.substring(name.length()-5));//输出00001
2. substring(int beginIndex, int endIndex)
substring(int beginIndex, int endIndex)
Returns a new string that is a substring of this string.
Intercept all characters from the string position beginIndex to the position endIndex-1. This method is closed at the beginning and opened at the end, that is, including the characters at the beginIndex position. But the character at endIndex position is not included.
Example:
String name="weicc-20100107-00001"; System.out.println(name.substring(name.length()-5,name.length()));//输出00001
For more java knowledge, please pay attention to the java basic tutorial column.
The above is the detailed content of How to intercept the last few characters of a string in java. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
