Create Java Class with Different AM

Written by admin on . Posted in Learn By Example

3 Flares Twitter 0 Facebook 1 Google+ 2 Email -- Email to a friend 3 Flares ×

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)

Leave a comment

3 Flares Twitter 0 Facebook 1 Google+ 2 Email -- Email to a friend 3 Flares ×