Sunday revision java
package com.company;
class employee10{
int salary;
public employee10(){
System.out.println("I am default constructor");
}
public int employee10(int salary){
this.salary=salary;
return salary;
}
}
class sunday{
int a=0;
String s="rohan";
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
public String getS() {
return s;
}
public void setS(String s) {
this.s = s;
}
}
class factorial {
public static int meth(int n) {
if (n == 0 || n == 1) {
return 1;
}
else {
return n*meth(n-1);
}
}
}
public class CWR_SundayRevision {
public static void main(String[] args) {
char[] ch = {'=', 'r', '3', '@', 'E', '+'};
// Sweeping an array
char v=0;
int g= Math.floorDiv(ch.length,2);
for(int i=0;i<g;i++){
v=ch[i];
ch[i]=ch[ch.length-i-1];
ch[ch.length-i-1]=v;
}
for (char e:ch
) {
System.out.println(e);
}
// Printing an array in reverse order
// for(int i=ch.length-1;i>=0;i--){
// System.out.println(ch[i]);
// }
// int [] [] [] points= new int[20][5][2];
// System.out.println(points.length);
// Adding two array
// int[] marks1={4,5,6,8,9,6,8,10,5,1};
// int[] marks2={2,4,7,2,3,0,7,1,5,1};
// for(int i=0;i<marks1.length;i++){
// int c= marks1[i]*marks2[i];
// System.out.print(c+" ");
// Multi dimensional
// int[][] m1= new int[2][3];
// m1[0][0]=2;
// m1[0][1]=3;
// m1[0][2]=67;
// m1[1][0]=90;
// m1[1][1]=89;
// m1[1][2]=87;
//
// int[][] m2= new int[2][3];
// m2[0][0]=25;
// m2[0][1]=43;
// m2[0][2]=7;
// m2[1][0]=9;
// m2[1][1]=80;
// m2[1][2]=67;
//// adding two-d array
// for(int i=0;i<m1.length;i++){
// for(int j=0;j<m2.length+1;j++){
// int c= m1[i][j]*m2[i][j];
// System.out.print(c+" ");
// }
// }
// Factorial by recursion
// factorial obj= new factorial();
// System.out.println( obj.meth(5));
// Getter and Setter
// sunday obj=new sunday();
// obj.setA(8907);
// System.out.println(obj.getA());
// obj.setS("hasdjglasfjlhgjlfgluyfguyegfuygeruylfgyjgfuywgeuyf6348758679482");
// System.out.println(obj.getS());
// Constructor
// employee10 obj= new employee10();
}
}
Comments
Post a Comment