Languages
[Edit]
EN

Java - get last character from string

11 points
Created by:
halfera
411

Problem:

How to get the last character from string in java?

I have: "abc"
I want: "c"
String str = "abc";
System.out.println(str); // abc
// ..
System.out.println(str); // c

Solution:

String str = "abc";
System.out.println(str.charAt(str.length() - 1)); // c

References: 

  1. Java - get last character of string

Docs:

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join