KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Ok, what I want to know is is there a way with Java to do what Python can do below... string_sample = "hello world" string_sample[:-1] >>> "hello world" string_sample[-1] >>> "d" string_sample[3] >>> "l" Because it seems to me that Java make you work for the same result (I'm particularly getting at having to use 2 numbers every time and the lack of a -1 to indicate last character) String string_sample = "hello world"; string_sample.substring(0,string_sample.length()-1); >>> "hello world" string_sample.substringstring_sample.length()]; >>> "d" string_sample.(3,4); >>> "l" I haven't gotten on to arrays/lists yet in Java so really hoping Java has something easier than this Edit: Ammended 'i' to 'l' for string_sample[3]. Well spotted Maroun!
Tags (comma-separated)
Save Edits
Cancel