JAVA Advance 2 practice set

 package com.company;


import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

interface rohan{
void meth1();
}
class dep{
@SuppressWarnings("dont")
@Deprecated
public void greet(){
System.out.println("Halllllo");
}
}
public class CWH_112_PracticeSet {

// P 3
@SuppressWarnings("Dont show any warning")
public static void main(String[] args) {

// Problem 2
// dep obj = new dep();
// obj.greet();

// p 4
// Method 1
// rohan r= new rohan() {
// @Override
// public void meth1() {System.out.println("hello jee");}};
// r.meth1();
//// Method 2
// rohan r1= ()->{
// System.out.println("hello jee");
// };
//r.meth1();
// p 5
// Creating a file
for(int c=2;c<=9;c++) {
File f = new File("Table " + c + " .txt");
try {
f.createNewFile();
} catch (IOException e) {
System.out.println("Problem occurred");
e.printStackTrace();
}
String table = "";
for (int i = 1; i < 11; i++) {
table += c + "X" + i + "=" + (c * i);
table += "\n";
}
try {
FileWriter fw = new FileWriter("Table " + c + " .txt");
fw.write(table);
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//File folder =new File("Folder.folder","Table2.txt","\"Table3.txt");
// try {
// folder.createNewFile();
// } catch (IOException e) {
// e.printStackTrace();
// }

}
}

Comments