Create Java Class with Different AM
Here we will learn to create Class with different access modifiers.
package com.accessmodifier;
/*
* Here we will learn to create Class with different access modifiers.
* 1- Public
* 2- Default
*/
// As ClassWithAM class is public hence it needs to be declared in a java file with given name only.
public class ClassWithAM {
int j;
}
/*
* Default / Non Public class can be created in same package and in same Java
* file. No Access Modifier needs to be mentioned. Class with Default Access
* modifier can not be accessed outside package in which it is declared.
*/
class ClassWithoutAM {
public int i;
}
Trackback from your site.

Comments (1)
Java Beginners Tutorial Java access modifiers examples
| #
[...] Create Java Class with Public & Default Access Modifier [...]
Reply