Languages
[Edit]
EN

Java - get last character from string

11 points
Created by:
halfera
291

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:

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