Discussion about access Modifier and Package

Number of replies: 7

package pack1;
 
class X
{
    protected int i = 1221;
     
    void methodOfX()
    {
        System.out.println(i);
    }
}
 
public class MainClass
{
    public static void main(String[] args)
    {
        X x = new X();
         
        System.out.println(x.i);
         
        x.methodOfX();
    }
}

In reply to First post

Re: Discussion about access Modifier and Package

by Shakil Hossen Shawon (201-15-3562) -
package bubble_sort;

import java.util.Scanner;

public class bubble sort {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] a= new int[10];
int i,j,temp;
System.out.println("Enter a array: ");
for(i=0;i<10;i++)
{
a[i]= in.nextInt();
}

for(i=0;i<10-1;i++)
{
for(j=0;j<10-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}

System.out.println("After Bubble Sorting: ");

for(i=0;i<10;i++) {
System.out.println("a[" +i +"] = " +a[i]);
}

}

}
In reply to First post

Re: Discussion about access Modifier and Package

by Rahad Islam (201-15-3623) -
package bubble_sort;

import java.util.Scanner;

public class bubble sort {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] a= new int[10];
int i,j,temp;
System.out.println("Enter a array: ");
for(i=0;i<10;i++)
{
a[i]= in.nextInt();
}

for(i=0;i<10-1;i++)
{
for(j=0;j<10-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}

System.out.println("After Bubble Sorting: ");

for(i=0;i<10;i++) {
System.out.println("a[" +i +"] = " +a[i]);
}

}

}
In reply to First post

Re: Discussion about access Modifier and Package

by Ieshita Nasrin Bithi (201-15-3216) -
package bubble_sort;

import java.util.Scanner;

public class bubble sort {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] a= new int[10];
int i,j,temp;
System.out.println("Enter a array: ");
for(i=0;i<10;i++)
{
a[i]= in.nextInt();
}

for(i=0;i<10-1;i++)
{
for(j=0;j<10-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}

System.out.println("After Bubble Sorting: ");

for(i=0;i<10;i++) {
System.out.println("a[" +i +"] = " +a[i]);
}

}

}
In reply to First post

Re: Discussion about access Modifier and Package

by Md. Jahidul Islam (201-15-3368) -
package bubble_sort;
import java.util.Scanner;
public class bubble sort {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] a= new int[10];
int i,j,temp;
System.out.println("Enter a array: ");
for(i=0;i<10;i++)
{
a[i]= in.nextInt();
}

for(i=0;i<10-1;i++)
{
for(j=0;j<10-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}

System.out.println("After Bubble Sorting: ");
for(i=0;i<10;i++) {
System.out.println("a[" +i +"] = " +a[i]);
}

}

}
In reply to First post

Re: Discussion about access Modifier and Package

by Md. Nazmus Sakib (201-15-3419) -
package bubble_sort;


import java.util.Scanner;


public class bubble sort
{


public static void main (String[]args)
{

Scanner in = new Scanner (System.in);

int[] a = new int[10];

int i, j, temp;

System.out.println ("Enter a array: ");

for (i = 0; i < 10; i++)

{

a[i] = in.nextInt ();

}


for (i = 0; i < 10 - 1; i++)

{

for (j = 0; j < 10 - 1 - i; j++)

{

if (a[j] > a[j + 1])

{

temp = a[j];

a[j] = a[j + 1];

a[j + 1] = temp;

}

}

}


System.out.println ("After The Bubble Sorting: ");


for (i = 0; i < 10; i++)
{

System.out.println ("a[" + i + "] = " + a[i]);

}


}


}
In reply to First post

Re: Discussion about access Modifier and Package

by Shazzad Shawon (201-15-3404) -
package bubble_sort;

import java.util.Scanner;

public class bubble sort {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] a= new int[10];
int i,j,temp;
System.out.println("Enter a array: ");
for(i=0;i<10;i++)
{
a[i]= in.nextInt();
}

for(i=0;i<10-1;i++)
{
for(j=0;j<10-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}

System.out.println("After Bubble Sorting: ");

for(i=0;i<10;i++) {
System.out.println("a[" +i +"] = " +a[i]);
}

}

}
In reply to First post

Re: Discussion about access Modifier and Package

by Pritom Basak (201-15-3342) -
package bubble_sort;

import java.util.Scanner;

public class bubble sort {

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] a= new int[10];
int i,j,temp;
System.out.println("Enter a array: ");
for(i=0;i<10;i++)
{
a[i]= in.nextInt();
}

for(i=0;i<10-1;i++)
{
for(j=0;j<10-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}

System.out.println("After Bubble Sorting: ");

for(i=0;i<10;i++) {
System.out.println("a[" +i +"] = " +a[i]);
}

}

}