answersLogoWhite

0

The private keyword denotes that the field or method is hidden from view of any other class.

class MyClass {

private int n; // n cannot be accessed by any class except MyClass

private void doSomething(){} // doSomething cannot be accessed by any class except MyClass

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is getters in java?

GETters and SETters are functions that GET and SET the value of a private variable.example:.........private int power;// -----------------------......................................................... // |.......................................................... // |........................................................... // |........................................................... // | The User Gets The value of power.......................................................... // |public int getPower(){ //...................... |return power;//


What does get mean in java and what is the function of it?

Instead of using public variables, people have a tendency to use it as private variable (They call it encapsulate) and only allow other access these variable via getters and setters. For example: class Calculator { private int a; public int getA(){ return a; } public void setA(int a){ this.a = a; } }


What is a int in java?

int is integer which means datatype


What is a variable type in Java?

int


How are java program statements terminated?

Each statement in Java ends with a semicolon, for example: int a; a = 5; int b = 10;


Is unsigned int var valid in java?

No. Java uses no unsigned numbers.


What is the abbrevations for int?

"int" is the abbreviation for an integer data type. In Java an int is specifically a 32-bit signed integer.


Write aprogram to print number between20 and30?

In Java, put the following within the main() method:for (int i = 20; i


Change int to string in java?

String.valueOf(number);


What is a simple java code and explain what the code does?

int a;This simple Java statement declares an integer.


How do you convert string to int in Java?

One can convert a string variable to an int variable in Java using the parse integer command. The syntax is int foo = Integer.parseInt("1234"). This line will convert the string in the parenthesis into an integer.


What do you mean by encasulation and examples in java?

I suppose you mean "encapsulation". It basically refers to "information hiding". That is, in a class, the details of how information is stored is hidden from the outside. Here is a typical example in Java: class Person { private int age; public int getAge() {return age;} public void setAge(int parameterAge) {age = parameterAge;} } Note that the field (or variable) "age" is declared as "private"; that means that it can't be accessed directly from the outside, and the programmer of this class is free to change the way the information is stored at any moment, without breaking compatibility with any code that uses the class. Access to the information is via the public "get" and "set" methods; the signature of these methods should not change.