These programs covered all types of core java programs
1.Inputs from keyboard and print them.
import java.io.*;
class input
{
public static void main(String args[])
{
try
{
int a[]=new int[5];
InputStreamReader ir=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(ir);
System.out.println(“enter values”);
for(int i=0;i<5;i++)
{
String x=br.readLine();
// System.out.println(“the values of are”+x);
int y=Integer.parseInt(x);
a[i]=y;
}
for(int i=0;i<5;i++)
System.out.println(a[i]);
}
catch(Exception e)
{ }
}
}
2.To find power of a given number.
class power
{
int function(int m,int n)
{
int p=1;
for(int i=1;i<=n;i++)
p*=m;
return p;
}
}
class power1
{
public static void main(String args[])
{
power . . . → Read More: java programs
Recent Comments