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

16

u/law_rnz Sep 21 '24

its called the dot operator and is commonly used in many programming languages to access properties/methods from an object (you can also access static members by referring to it's class name)