Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

whats the difference between public static void and private static void in java

MatthewXia
MatthewXia

i have no idea........................................................................................really...................................................................................idk why.................................................................................but i actully dont know.....................................................i shud tho....................................................why.................................................................and..........................................................wut..........................................................am..........................................................i..........................................................doing..........................................................with..........................................................my..........................................................life?

2 years ago

Voters

Comments

TopNew
2
Coder100
Coder100

So like, if a person was a class:

class Person { public name() {} private creditCard() {} } Person me = new Person();

Others should be able to call me.name() to get my name, but shouldn't be able to call me.creditCard() because only I can access that, nothing else can.

2 years ago
1
Coder100
Coder100
class Something { public a() { } private b() { } } Something c = new Something(); c.a(); // public so you can call it c.b(); // ERROR is private so you can't
2 years ago
Load more