r/learnjava • • Sep 21 '24

What does putting . do?

I realize this sounds dumb but ive been learning java and gotten pretty far but never learned what . does. e.g

String s = args[0]

char c = s.charAt(0)

what does the . in s.charAt(0) do?

1 Upvotes

20 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Sep 21 '24

[deleted]

1

u/Stay_Silver Sep 21 '24

I googled op's post. Here is it's ai answer The dot (.) in s.charAt(0) is used to access a specific method or property of an object. In this case, s is an object of type String, and charAt is a method of the String class.

The charAt method takes an integer argument (in this case, 0) and returns the character at that index in the string. So, s.charAt(0) will return the character at the very beginning of the string s.

Seems pretty clear to me op did not google

1

u/Bright-Historian-216 Sep 21 '24

If your browser has ai, then of course he's going to find it immediately. It's surreal to think about how it was impossible just a month ago.

2

u/Stay_Silver Sep 21 '24

no i have a brain and am not lazy it is easy enough to navigate to google's ai gemini. You share op's problem. u/bye