diff --git a/src/A.java b/src/A.java
new file mode 100644
index 0000000..42e0766
--- /dev/null
+++ b/src/A.java
@@ -0,0 +1,37 @@
+
+
+//class B extends A{
+// static protected int method1(int a, int b){
+// return 0;
+// }//not
+
+// public int method1(int a , int b){
+// return 0;
+// }//yes//overrides
+//
+// public static void main(String args[]){
+// method1(5,6);
+// }
+
+// private int method1(int a , int b){
+// return 0;
+// }//not
+
+// public short method1(int a , int b){
+// return 0;
+// }//Incompatible return type
+
+
+// private int method1(int a , long b){
+// return 0;
+// }//yes//overloads}
+public class A {
+
+ //protected int method1(int a, int b) {
+ //return 0;
+ public static void main(String args[]){
+
+
+ }
+}
+
diff --git a/src/Add.class b/src/Add.class
new file mode 100644
index 0000000..4ffd136
Binary files /dev/null and b/src/Add.class differ
diff --git a/src/AnnotationBasics.java b/src/AnnotationBasics.java
new file mode 100644
index 0000000..098def3
--- /dev/null
+++ b/src/AnnotationBasics.java
@@ -0,0 +1,55 @@
+import java.lang.reflect.*;
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface MyAnno{
+ String str();
+ int val();
+}
+@Retention(RetentionPolicy.RUNTIME)
+@interface what{
+ String description();
+}
+
+@MyAnno(str ="AnnotationBasics Class", val = 621315)
+@what(description = "An annotation test example")
+public class AnnotationBasics{
+
+
+ @MyAnno(str ="Annotation Example ", val =841655)
+ @what(description = "An annotation test method.")
+ public static void myMeth() {//this annotation annotates the myMeth() method
+ AnnotationBasics annotationBasics = new AnnotationBasics();
+ try {
+
+ Annotation annotation[] = annotationBasics.getClass().getAnnotations();
+ //class> c = annotationBasics.getClass();
+ //Method method = c.getMethod("myMeth");
+
+ //MyAnno myAnn = method.getAnnotation(MyAnno.class);
+ System.out.println("\nAll annotations for AnnotationBasics class.");
+
+ for(Annotation annotation1 : annotation){
+ System.out.println(annotation1);
+ }
+ Method method = annotationBasics.getClass().getMethod("myMeth");
+ annotation = method.getAnnotations();
+
+
+ System.out.println("\nPrinting all annotations for myMeth().");
+ for(Annotation annotation1 : annotation){
+ System.out.println(annotation1);
+ }
+
+
+ }catch (NoSuchMethodException e){
+ System.out.println("Method not found.");
+ }
+
+ }
+ public static void main(String args[]){
+ myMeth();
+ }
+
+
+}
diff --git a/src/AnnotationJava.java b/src/AnnotationJava.java
new file mode 100644
index 0000000..c84cbc4
--- /dev/null
+++ b/src/AnnotationJava.java
@@ -0,0 +1,67 @@
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+import java.util.*;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@interface FamilyBudget {
+ String userRole() default "guest";
+ int budgetLimit() default 100;
+}
+
+class FamilyMember {
+ @FamilyBudget( userRole = "senior", budgetLimit = 100)
+ public void seniorMember(int budget, int moneySpend) {
+ System.out.println("Senior Member");
+ System.out.println("Spend: " + moneySpend);
+ System.out.println("Budget Left: " + (budget - moneySpend));
+ }
+
+ @FamilyBudget(userRole = "junior", budgetLimit =50)
+ public void juniorUser(int budget, int moneySpend) {
+ System.out.println("Junior Member");
+ System.out.println("Spend: " + moneySpend);
+ System.out.println("Budget Left: " + (budget - moneySpend));
+ }
+ @FamilyBudget(userRole = "guest", budgetLimit = 200)
+ public void guestUser(int budget, int moneySpend) {
+ System.out.println("Guest Member");
+ System.out.println("Spend: " + moneySpend);
+ System.out.println("Budget Left: " + (budget - moneySpend));
+ }
+}
+
+class Solution {
+ public static void main(String[] args) {
+ Scanner in = new Scanner(System.in);
+ int testCases = Integer.parseInt(in.nextLine());
+ while (testCases > 0) {
+ String role = in.next();
+ int spend = in.nextInt();
+ try {
+ Class annotatedClass = FamilyMember.class;
+ Method[] methods = annotatedClass.getMethods();
+ for (Method method : methods) {
+ if (method.isAnnotationPresent(FamilyBudget.class)) {
+ FamilyBudget family = method.getAnnotation(FamilyBudget.class);
+ String userRole = family.userRole();
+ int budgetLimit = family.budgetLimit();
+ if (userRole.equals(role)) {
+ if(spend <= budgetLimit){
+ method.invoke(FamilyMember.class.newInstance(), budgetLimit, spend);
+ }else{
+ System.out.println("Budget Limit Over");
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ testCases--;
+ }
+ }
+}
+
+
+
diff --git a/src/AnotherFrame.java b/src/AnotherFrame.java
new file mode 100644
index 0000000..41ed4d4
--- /dev/null
+++ b/src/AnotherFrame.java
@@ -0,0 +1,18 @@
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+
+class AnotherFrame extends JFrame
+{
+ public AnotherFrame() {
+ super("Another GUI");
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ add(new JLabel("Empty JFrame"));
+ pack();
+ setVisible(true);
+ }
+ public static void main(String args[]){
+ new AnotherFrame();
+
+ }
+}
diff --git a/src/CardlayoutDemo.java b/src/CardlayoutDemo.java
new file mode 100644
index 0000000..d63acc5
--- /dev/null
+++ b/src/CardlayoutDemo.java
@@ -0,0 +1,50 @@
+import java.applet.Applet;
+import java.awt.*;
+//import java.awt.Label;
+
+
+
+//
+
+class CardLayoutDemo extends Applet {
+
+ Checkbox Windows7, Windows8, windows10, Android, Mac, Solaris;
+ Panel osCards;
+ Frame frame;
+
+ CardLayout cardLayout;
+ Button Windows, Other;
+ public void init(){
+ Windows = new Button("Windows");
+ Other = new Button("Other");
+
+ frame = new Frame("HELLO");
+ frame.add(Windows);
+ frame.add(Other);
+
+ frame.setVisible(true);
+ frame.setSize(500,500);
+ cardLayout = new CardLayout();
+ //osCards = new Panel();
+ frame.setLayout(cardLayout);
+
+ Windows7 = new Checkbox("Windows7", null, true);
+
+
+
+
+ }
+// public void actionPerformed(ActiveEvent activeEvent){
+// if(activeEvent.getSource() == Windows){
+// cardLayout.showStatus("Windows");
+// }
+// }
+ public static void main(String args[]){
+ CardLayoutDemo cardLayoutDemo = new CardLayoutDemo();
+ }
+
+
+
+
+}
diff --git a/src/CompareArray.java b/src/CompareArray.java
new file mode 100644
index 0000000..176e9e0
--- /dev/null
+++ b/src/CompareArray.java
@@ -0,0 +1,33 @@
+import java.util.Scanner;
+class CompareArray{
+ public static void main(String []args){
+ //Input
+ Scanner sc= new Scanner(System.in);
+ int n=sc.nextInt();
+ String []s=new String[n+2];
+ for(int i=0;i(s[j])){
+ String temp = s[i];
+ s[i] = s[j];
+ s[j] = temp;
+
+ }
+ }
+ }
+
+
+
+ //Output
+ for(int i=0;i 0) {
+ String input = in.nextLine();
+ char arr[]= input.toCharArray();
+ String string = checkRepeats(arr);
+
+ Matcher m = p.matcher(input);
+
+ while (m.find()) {
+ input = input.replaceAll(regex, "");
+ }
+
+ System.out.println(input);
+ }
+
+ in.close();
+ }
+
+ static String checkRepeats(char sentence[]){
+ int i = 0, len, words = 0, again = 0;
+ len = sentence.length;
+ char wrd[]= new char[20];
+ char sen[]= new char[20];
+ for( i=0; i tokens = new ArrayList<>();
+ Scanner lineScanner = new Scanner(scanner.nextLine());
+
+ while (lineScanner.hasNext()) {
+ tokens.add(lineScanner.next());
+ }
+
+ lineScanner.close();
+ System.out.println(tokens);
+ }
+
+ scanner.close();
+ }
+ }
+
+ }catch (IOException e){
+ System.out.println("IOException caught.");
+ }
+
+ }
+ }
+}
+
+
+
+import java.util.Scanner;
+
+class EOF
+{
+ // Read multi-line input from console in Java using Scanner class
+ public static void main(String[] args)
+ {
+ Scanner scanner = new Scanner(System.in);
+ int i =1;
+ while (scanner.hasNextLine()) {
+ String tokens = scanner.nextLine().trim();
+ System.out.println(i+" "+tokens);
+ i++;
+ }
+
+ scanner.close();
+ }
+}
diff --git a/src/FXMLDocumentController.java b/src/FXMLDocumentController.java
new file mode 100644
index 0000000..4456e25
--- /dev/null
+++ b/src/FXMLDocumentController.java
@@ -0,0 +1,80 @@
+
+
+
+
+
+import javafx.fxml.FXML;
+import javafx.scene.control.Label;
+import javafx.fxml.Initializable;
+import javafx.scene.media.MediaPlayer;
+import javafx.scene.media.MediaView;
+import javafx.stage.FileChooser;
+
+import javax.swing.*;
+import javax.swing.plaf.FileChooserUI;
+import java.awt.event.ActionEvent;
+import java.io.File;
+import java.util.ResourceBundle;
+
+/*
+
+
+
+*/
+
+abstract class FXMLDocumentController implements Initializable{
+
+ private String filePath;
+ private MediaPlayer player;
+
+
+
+ @FXML
+ private Label label;
+
+ @FXML
+ private MediaView mediaView;
+
+ @FXML
+ private void handleButtonAction(ActionEvent ae){
+ FileChooser fileChooser = new FileChooser();
+ FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("mp4 file please", ".mp4")
+
+ fileChooser.getExtensionFilters().add(filter);
+
+ File file= fileChooser.showOpenDialog(null);
+ filePath = file.toURI().toString();
+ if(filePath != null){
+ Media media = new Media("hjhkjh");
+ player = new MediaPlayer(media);
+
+ mediaView.setMediaPlayer(player);
+ player.play();
+
+// public MediaTrack(double length, String fileUrl, ScheduledExecutorService uiScheduler) {
+// this.length = length;
+// this.timer = uiScheduler;
+// Media media = new Media(fileUrl);
+// Platform.runLater(() -> {
+// player = new MediaPlayer(media);
+// player.setOnError(() ->
+// logger.error("Failed to play media "+fileUrl, player.getError())
+// );
+// player.setOnEndOfMedia(this::stop
+// );
+// });
+
+
+
+
+ }
+
+ @Override
+ public void initializable (url, ResourceBundle){
+ //TODO
+
+
+ }
+
+
+}
diff --git a/src/FileInputStreamDemo.java b/src/FileInputStreamDemo.java
new file mode 100644
index 0000000..d284ddb
--- /dev/null
+++ b/src/FileInputStreamDemo.java
@@ -0,0 +1,67 @@
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.FileInputStream;
+
+class FileInputStreamDemo {
+
+ public static void main(String args[])// throws IOException, FileNotFoundException
+ {
+ int size;
+ String pathname= "C:\\Tensorflow\\models-master\\samples\\languages\\java\\MediaPlayerAnnoying\\src\\FileInputStreamDemo.java";
+ File file= new File(pathname);
+ try(FileInputStream f = new FileInputStream(file)){
+//Reading first n bytes
+ System.out.println("Total size available= "+ (size= f.available()));
+ int n = size / 40;
+ System.out.println("First "+n+ "Bytes of the file one read at a time.");
+ for(int i =0; i {
+
+ T ob1;
+ V ob2;
+ TwoGen(T o1, V o2){
+ ob1 = o1;
+ ob2 = o2;
+ }
+ void showTypes(){
+ System.out.println("Type of T is "+ ob1.getClass().getName());
+ //System.out.println("getMethods "+ ob1.getClass().getMethods());
+ //System.out.println("isAnonymousClass "+ ob1.getClass().isAnonymousClass());
+
+ System.out.println("Type of V is "+ ob2.getClass().getName());
+
+ }
+ T getOb1(){
+ return ob1;
+ }
+ V getOb2(){
+ return ob2;
+ }
+}
+class GenericsWithTwoTypeParameters{
+ public static void main(String args[]){
+ TwoGen twoGen = new TwoGen<>(6636316336302.0, "Geneerics with two type parameteres");
+ twoGen.showTypes();
+ Double n = twoGen.getOb1();
+ System.out.print("Value: "+ n );
+
+ String str = twoGen.getOb2();
+ System.out.println(" String : "+ str);
+ }
+}
diff --git a/src/HourGlass.java b/src/HourGlass.java
new file mode 100644
index 0000000..daf0bab
--- /dev/null
+++ b/src/HourGlass.java
@@ -0,0 +1,41 @@
+import java.util.Scanner;
+
+public class HourGlass {
+ private static final Scanner scanner = new Scanner(System.in);
+
+ public static void main(String[] args) {
+ //int[][] a = new int[8][8];
+
+// for (int i = 0; i < 6; i++) {
+// //String[] arrRowItems = scanner.nextLine().split(" ");
+// //scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
+//
+// for (int j = 0; j < 6; j++) {
+// //int aItem = Integer.parseInt(arrRowItems[j]);
+// a[i][j] = scanner.nextInt();
+// }
+// }
+ int[][] a={{1,2,3,4,5,6},{7,8,9,1,2,3},{4,5,6,7,8,9},{1,2,3,4,5,6},{7,8,9,1,2,3},{4,5,6,7,8,9,}};
+ int sum[][] = new int[6][6];
+ int i1=0,i2=0,i3=0,i4=2,i5=3,i6=3,i7=3;
+ int j1=0,j2=1,j3=2,j4=2,j5=0,j6=1,j7=2;
+ for(int r=0; r<4; r++){
+ for(int c=0; c<3; c++){
+ sum[r][c] = a[i1][j1]+ a[i2][j2]+ a[i3][j3] + a[i4][j4] +a[i5][j5]+a[i6][j6]+ a[i7][j7];
+ j1++;j2++;j3++;j4++;j5++;j6++;j7++;
+ }
+ i1++;i2++;i3++;i4++;i5++;i6++;i7++;
+ }
+ int max = sum[0][0];
+ for(int i=0;i<5; i++){
+ for (int j = 0; j < 20; j++) {
+ if(sum[i][j] > max){
+ max = sum[i][j];
+ }
+ }
+ }
+ System.out.println(max);
+
+ scanner.close();
+ }
+}
diff --git a/src/InnerClass.java b/src/InnerClass.java
new file mode 100644
index 0000000..dd29785
--- /dev/null
+++ b/src/InnerClass.java
@@ -0,0 +1,65 @@
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.security.Permission;
+
+import static com.sun.tools.corba.se.idl.InterfaceState.Private;
+
+
+public class InnnerClass {
+
+ public static void main(String[] args) throws Exception {
+ DoNotTerminate.forbidExit();
+
+ try{
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+ int num = Integer.parseInt(br.readLine().trim());
+ Object o;// Must be used to hold the reference of the instance of the class Solution.Inner.Private
+
+// InnnerClass o = new InnnerClass();
+// o.Inner inner = o.new Inner();
+// ((Inner) inner).Private pri = inner.new Private();
+// pri.powerof2(num);
+
+
+
+
+
+
+ System.out.println("An instance of class: " + o.getClass().getCanonicalName() + " has been created");
+
+ }//end of try
+
+ catch (DoNotTerminate.ExitTrappedException e) {
+ System.out.println("Unsuccessful Termination!!");
+ }
+ }//end of main
+ static class Inner{
+ private class Private{
+ private String powerof2(int num){
+ return ((num&num-1)==0)?"power of 2":"not a power of 2";
+ }
+ }
+ }//end of Inner
+
+}//end of Solution
+
+class DoNotTerminate { //This class prevents exit(0)
+
+ public static class ExitTrappedException extends SecurityException {
+
+ private static final long serialVersionUID = 1L;
+ }
+
+ public static void forbidExit() {
+ final SecurityManager securityManager = new SecurityManager() {
+ @Override
+ public void checkPermission(Permission permission) {
+ if (permission.getName().contains("exitVM")) {
+ throw new ExitTrappedException();
+ }
+ }
+ };
+ System.setSecurityManager(securityManager);
+ }
+}
+
diff --git a/src/IntToString.java b/src/IntToString.java
new file mode 100644
index 0000000..15cf1e7
--- /dev/null
+++ b/src/IntToString.java
@@ -0,0 +1,48 @@
+import java.util.*;
+import java.security.*;
+public class IntToString {
+ public static void main(String[] args) {
+
+ DoNotTerminate.forbidExit();
+
+ try {
+ Scanner in = new Scanner(System.in);
+ int n = in.nextInt();
+ in.close();
+ //String s=???; Complete this line below
+
+ //Write your code here
+ String s = String.valueOf(n);
+
+
+ if (n == Integer.parseInt(s)) {
+ System.out.println("Good job");
+ } else {
+ System.out.println("Wrong answer.");
+ }
+ } catch (DoNotTerminate.ExitTrappedException e) {
+ System.out.println("Unsuccessful Termination!!");
+ }
+ }
+}
+
+//The following class will prevent you from terminating the code using exit(0)!
+class DoNotTerminate {
+
+ public static class ExitTrappedException extends SecurityException {
+
+ private static final long serialVersionUID = 1;
+ }
+
+ public static void forbidExit() {
+ final SecurityManager securityManager = new SecurityManager() {
+ @Override
+ public void checkPermission(Permission permission) {
+ if (permission.getName().contains("exitVM")) {
+ throw new ExitTrappedException();
+ }
+ }
+ };
+ System.setSecurityManager(securityManager);
+ }
+}
diff --git a/src/JavaClass.java b/src/JavaClass.java
new file mode 100644
index 0000000..15da88a
--- /dev/null
+++ b/src/JavaClass.java
@@ -0,0 +1,32 @@
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+public class JavaClass {
+
+ public static void main(String[] args) {
+ /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
+ Scanner scanner = new Scanner(System.in);
+ int n = scanner.nextInt();
+
+
+ List list = new ArrayList<>();
+ for(int i =0;i ((pow(2, 63))-1) ){
+ System.out.println(x + " can't be fitted anywhere.");
+ }
+ System.out.println(x+" can be fitted in:");
+ if(x >= -128 && x <= 127)System.out.println("* byte");
+
+ if (x >= -(pow(2, 15)) && x <= ((pow(2, 15))-1)){
+ System.out.println("* short");
+ }
+ if (x >= -(pow(2, 31)) && x <= ((pow(2, 31))-1)){
+ System.out.println("* int");
+ }
+ if (x >= -(pow(2, 63)) && x <= ((pow(2, 63))-1)){
+ System.out.println("* long");
+ }
+
+
+ }catch(Exception e)
+ {
+ System.out.println(sc.next()+" can't be fitted anywhere.");
+ }
+
+ }
+ }
+}
+
+
+
diff --git a/src/JavaDateAndTime.java b/src/JavaDateAndTime.java
new file mode 100644
index 0000000..f279eb3
--- /dev/null
+++ b/src/JavaDateAndTime.java
@@ -0,0 +1,130 @@
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.time.format.TextStyle;
+import java.util.Date;
+import java.util.Locale;
+
+class Result {
+
+ /*
+ * Complete the 'findDay' function below.
+ *
+ * The function is expected to d a STRING.
+ * The function accepts following parameters:
+ * 1. INTEGER month
+ * 2. INTEGER day
+ * 3. INTEGER year
+ */
+
+ public static String findDay(int month, int day, int year) {
+ Date date = new Date(year, month, day);
+ String d = new String();
+ long milli = (date.getSeconds()) * 1000;
+
+ switch(date.getDay()){
+ case 0: d ="Sunday"; break;
+ case 1: d ="Monday"; break;
+ case 2: d ="Tuesday"; break;
+ case 3: d ="Wednesday"; break;
+ case 4: d ="Thursday"; break;
+ case 5: d ="Friday"; break;
+ case 6: d ="Saturday"; break;
+ }
+ return d;
+ // return findDay(month, day, year);
+
+ }
+
+}
+
+public class JavaDateAndTime {
+ public static void main(String[] args) {//throws ParseException {
+ String input_date="date/month/year";
+ SimpleDateFormat format1=new SimpleDateFormat("dd/MM/yyyy");
+ Date dt1=format1.parse(input_date);
+ DateFormat format2=new SimpleDateFormat("EEEE");
+ return format2.format(dt1);
+
+
+ Calendar c = Calendar.getInstance();
+ c.setTime(2015, 8, 5);
+ int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
+
+
+
+
+
+
+ String d = new String();
+ Date date = new Date();
+ date.setYear(2015);
+ date.setMonth(8);
+ date.setDate(6);
+
+
+ switch(date.getDay()){
+ case 0: d ="Sunday"; break;
+ case 1: d ="Monday"; break;
+ case 2: d ="Tuesday"; break;
+ case 3: d ="Wednesday"; break;
+ case 4: d ="Thursday"; break;
+ case 5: d ="Friday"; break;
+ case 6: d ="Saturday"; break;
+ }
+ //return d;
+ LocalDate.parse( // Generate `LocalDate` object from String input.
+ "23/2/2010" ,
+ DateTimeFormatter.ofPattern( "dd/MM/uuuu" )
+ )
+ .getDayOfWeek() // Get `DayOfWeek` enum object.
+ .getDisplayName( // Localize. Generate a String to represent this day-of-week.
+ TextStyle.SHORT_STANDALONE , // How long or abbreviated. Some languages have an alternate spelling for "standalone" use (not so in English).
+ Locale.US // Or Locale.CANADA_FRENCH and such. Specify a `Locale` to determine (1) human language for translation, and (2) cultural norms for abbreviation, punctuation, etc.
+ );
+
+
+
+ String input = "23/2/2010";
+ DateTimeFormatter formatter = DateTimeFormat.forPattern( "d/M/yyyy" );
+ LocalDate localDate = formatter.parseLocalDate( input );
+
+ int dayOfWeek = localDate.getDayOfWeek(); // Follows ISO 8601 standard, where Monday = 1, Sunday = 7.
+ Locale locale = Locale.US; // Locale specifies the human language to use in determining day-of-week name (Tuesday in English versus Mardi in French).
+ DateTimeFormatter formatterOutput = DateTimeFormat.forPattern( "E" ).withLocale( locale );
+ String output = formatterOutput.print( localDate ); // 'E' is code for abbreviation of day-of-week name. See Joda-Time doc.
+ String outputQuébécois = formatterOutput.withLocale( Locale.CANADA_FRENCH ).print( localDate
+
+
+
+
+
+ System.out.println(d); //System.out.println(finalDay);
+
+ long milliseconds = (date.getSeconds()) * 1000;
+ date = new Date(milliseconds);
+
+return findDay(month, day, year);
+
+
+
+ throws NullPointerException, IOException {
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
+ BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
+
+ String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
+
+ int month = Integer.parseInt(firstMultipleInput[0]);
+
+ int day = Integer.parseInt(firstMultipleInput[1]);
+
+ int year = Integer.parseInt(firstMultipleInput[2]);
+
+ String res = Result.findDay(month, day, year);
+
+ bufferedWriter.write(res);
+ bufferedWriter.newLine();
+
+ bufferedReader.close();
+ bufferedWriter.close();
+ }
+}
diff --git a/src/JavaInterface.java b/src/JavaInterface.java
new file mode 100644
index 0000000..8bd111c
--- /dev/null
+++ b/src/JavaInterface.java
@@ -0,0 +1,41 @@
+import java.util.*;
+interface AdvancedArithmetic{
+ int divisor_sum(int n);
+}
+
+//Write your code here
+
+class MyCalculator implements AdvancedArithmetic{
+ int sum=0;
+ public int divisor_sum(int n){
+ for(int i=1;i<=n; i++){
+ if(n%i == 0){
+ sum+=i;
+ }
+ }
+ return sum;
+ }
+}
+
+class JavaInterface{
+ public static void main(String []args){
+ MyCalculator my_calculator = new MyCalculator();
+ System.out.print("I implemented: ");
+ ImplementedInterfaceNames(my_calculator);
+ Scanner sc = new Scanner(System.in);
+ int n = sc.nextInt();
+ System.out.print(my_calculator.divisor_sum(n) + "\n");
+ sc.close();
+ }
+ /*
+ * ImplementedInterfaceNames method takes an object and prints the name of the interfaces it implemented
+ */
+ static void ImplementedInterfaceNames(Object o){
+ Class[] theInterfaces = o.getClass().getInterfaces();
+ for (int i = 0; i < theInterfaces.length; i++){
+ String interfaceName = theInterfaces[i].getName();
+ System.out.println(interfaceName);
+ }
+ }
+}
+
diff --git a/src/JavaLambdaExpression.java b/src/JavaLambdaExpression.java
new file mode 100644
index 0000000..9b93ea2
--- /dev/null
+++ b/src/JavaLambdaExpression.java
@@ -0,0 +1,95 @@
+import java.io.*;
+import java.util.*;
+interface PerformOperation {
+ boolean check(int a);
+}
+class MyMath {
+ public static boolean checker(PerformOperation p, int num) {
+ return p.check(num);
+ }
+ PerformOperation isOdd(){
+ PerformOperation Obj= new PerformOperation() {
+ @Override
+ public boolean check(int a) {
+ if(a%2 == 0){return false;}
+ else{return true;}
+ }
+ };
+ return Obj;
+ }
+
+ PerformOperation isPrime(){
+ PerformOperation Obj = new PerformOperation() {
+ @Override
+ public boolean check(int a) {
+ int flag =1;
+ boolean dic = false;
+ if(a==1 || a==2 ){dic = true;}
+ if(a < 0){dic = false;}
+
+ for(int i =2; i < a/2; i++){
+ if(a%i == 0 ){flag =0;break;}
+ }
+ if(flag == 0){dic = false;}
+ if(flag == 1){dic= true;}
+ return dic;
+ }
+ };
+ return Obj;
+ }
+ PerformOperation isPalindrome(){
+ PerformOperation Obj = new PerformOperation() {
+ @Override
+ public boolean check(int a) {
+ int rem=0, rev=0, temp =a;
+ boolean dic= false;
+ while(a != 0){
+ rem = a%10;
+ rev = rev*10 + rem;
+ a /=10;
+ }
+ if(temp == rev){
+ dic = true;
+ }else{dic = false;}
+ return dic;
+ }
+ };
+ return Obj;
+ }
+
+ // Write your code here
+}
+public class JavaLambdaExpression {
+
+ public static void main(String[] args) throws IOException {
+ MyMath ob = new MyMath();
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+ int T = Integer.parseInt(br.readLine());
+ PerformOperation op;
+ boolean ret = false;
+ String ans = null;
+ while (T-- > 0) {
+ String s = br.readLine().trim();
+ StringTokenizer st = new StringTokenizer(s);
+ int ch = Integer.parseInt(st.nextToken());
+ int num = Integer.parseInt(st.nextToken());
+ if (ch == 2) {
+ op = ob.isPrime();
+ ret = ob.checker(op, num);
+ ans = (ret) ? "PRIME" : "COMPOSITE";
+ }
+
+ if (ch == 1) {
+ op = ob.isOdd();
+ ret = ob.checker(op, num);
+ ans = (ret) ? "ODD" : "EVEN";
+ } else if (ch == 3) {
+ op = ob.isPalindrome();
+ ret = ob.checker(op, num);
+ ans = (ret) ? "PALINDROME" : "NOT PALINDROME";
+
+ }
+ System.out.println(ans);
+ }
+ }
+ }
diff --git a/src/JavaMD5Hashing.java b/src/JavaMD5Hashing.java
new file mode 100644
index 0000000..2808f1d
--- /dev/null
+++ b/src/JavaMD5Hashing.java
@@ -0,0 +1,26 @@
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Scanner;
+
+
+public class JavaMD5Hashing {
+ public static void main(String ... args) throws UnsupportedEncodingException, NoSuchAlgorithmException {
+
+ Scanner scanner = new Scanner(System.in);
+
+ String yourString = scanner.nextLine();
+
+ MessageDigest md = MessageDigest.getInstance("MD5");
+
+ String hashText = new BigInteger(1,md.digest(yourString.getBytes("UTF-8"))).toString(16);
+
+
+ //System.out.println(String.format("%x", new BigInteger(1, yourString.getBytes("UTF-8"))));
+ while (hashText.length() < 32){
+ hashText = "0"+hashText;
+ }
+ System.out.println(hashText);
+ }
+}
diff --git a/src/JavaSHA_256Hashing.java b/src/JavaSHA_256Hashing.java
new file mode 100644
index 0000000..a988ab7
--- /dev/null
+++ b/src/JavaSHA_256Hashing.java
@@ -0,0 +1,27 @@
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Scanner;
+
+
+public class JavaSHA_256Hashing {
+ public static void main(String ... args) throws NoSuchAlgorithmException {
+
+ Scanner scanner = new Scanner(System.in);
+
+ String yourString = scanner.nextLine();
+
+ MessageDigest md = MessageDigest.getInstance("SHA-256");
+ md.reset();
+ md.update(yourString.getBytes());
+
+ String hashText = new BigInteger(1,md.digest()).toString(16);
+
+
+ //System.out.println(String.format("%x", new BigInteger(1, yourString.getBytes("UTF-8"))));
+// while (hashText.length() < 32){
+// hashText = "0"+hashText;
+// }
+ System.out.println(hashText);
+ }
+}
diff --git a/src/LambdaExpression.java b/src/LambdaExpression.java
new file mode 100644
index 0000000..f3220db
--- /dev/null
+++ b/src/LambdaExpression.java
@@ -0,0 +1,44 @@
+
+interface NumericTest{
+ int test(int n, int d);
+}
+
+public class LambdaExpression {
+ public static void main(String args[]){
+ // NumericTest isFactor = (n,d) -> (n%2)==0;
+
+// if(isEven.test(8)){
+// System.out.println(8 +" is Even");
+// }
+// if(! (isEven.test(-98989))){
+// System.out.println(-98989 +" is odd");
+//
+// }
+//
+// NumericTest isNotNegative = (n) ->(n >= 0);
+// if(! (isNotNegative.test(-51615165))){
+// System.out.println("Number is positive");
+//// }
+// if(isFactor.test(5,2)){
+// System.out.println("true");
+// }if(isFactor.test(268491618, 2)){
+// System.out.println("factor exists.");
+// }
+
+
+
+
+ NumericTest factorial = (n,j)->{
+ int result =1;
+ for(int i=1; i<=n;i++){
+ result*=i;
+ }
+ return result;
+ };
+
+ System.out.println("Facorial of 6 is : "+ factorial.test(6,0));
+
+
+ }
+
+}
diff --git a/src/MediaPlayer.java b/src/MediaPlayer.java
new file mode 100644
index 0000000..7b32c28
--- /dev/null
+++ b/src/MediaPlayer.java
@@ -0,0 +1,22 @@
+//import java.util.concurrent.ScheduledExecutorService;
+//
+//public class MediaPlayer {
+// ScheduledExecutorService uiScheduler;
+//
+//
+//
+//
+// public MediaTrack(double length, String fileUrl, ScheduledExecutorService uiScheduler) {
+// this.length = length;
+// this.timer = uiScheduler;
+// Media media = new Media(fileUrl);
+// Platform.runLater(() -> {
+// player = new MediaPlayer(media);
+// player.setOnError(() ->
+// logger.error("Failed to play media "+fileUrl, player.getError())
+// );
+// player.setOnEndOfMedia(this::stop
+// );
+// });
+// }
+//}
diff --git a/src/MediaTrack.java b/src/MediaTrack.java
new file mode 100644
index 0000000..70511a4
--- /dev/null
+++ b/src/MediaTrack.java
@@ -0,0 +1,31 @@
+import javafx.application.Platform;
+
+import javax.print.attribute.standard.Media;
+import java.util.Timer;
+import java.util.concurrent.ScheduledExecutorService;
+
+abstract class MediaTrack {
+ //ScheduledExecutorService uiScheduler;
+ double length;
+ Timer timer;
+ Platform pt;
+
+ Player player;
+
+
+
+ public MediaTrack(double length, String fileUrl, ScheduledExecutorService uiScheduler) {
+ this.length = length;
+ this.timer = uiScheduler;
+ Media media = new Media(fileUrl);
+ Platform.runLater(() -> {
+ player = new MediaPlayer(media);
+ player.setOnError(() ->
+ logger.error("Failed to play media "+fileUrl, player.getError())
+ );
+ player.setOnEndOfMedia(this::stop
+ );
+ });
+ }
+
+}
diff --git a/src/MethodOverriding.java b/src/MethodOverriding.java
new file mode 100644
index 0000000..0b77462
--- /dev/null
+++ b/src/MethodOverriding.java
@@ -0,0 +1,36 @@
+
+class Sports{
+
+ String getName(){
+ return "Generic Sports";
+ }
+
+ void getNumberOfTeamMembers(){
+ System.out.println( "Each team has n players in " + getName() );
+ }
+}
+
+class Soccer extends Sports{
+ @Override
+ String getName(){
+ return "Soccer Class";
+ }
+
+ // Write your overridden getNumberOfTeamMembers method here
+ void getNumberOfTeamMembers(){
+ System.out.println( "Each team has 11 players in " + getName()+"{-truncated-}" );
+
+ }
+}
+
+public class MethodOverriding{
+
+ public static void main(String []args){
+ Sports c1 = new Sports();
+ Soccer c2 = new Soccer();
+ System.out.println(c1.getName());
+ c1.getNumberOfTeamMembers();
+ System.out.println(c2.getName());
+ c2.getNumberOfTeamMembers();
+ }
+}
diff --git a/src/MouseEventsDemo.java b/src/MouseEventsDemo.java
new file mode 100644
index 0000000..4da76a9
--- /dev/null
+++ b/src/MouseEventsDemo.java
@@ -0,0 +1,103 @@
+import javax.swing.*;
+import javax.swing.text.JTextComponent;
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+
+public class MouseEventsDemo extends Applet implements MouseListener, MouseMotionListener
+ , KeyListener {
+
+
+ String msg = "";
+ int mouseX =0, mouseY =0, i=0;
+
+ public void init(){
+ addMouseListener(this);
+ addMouseMotionListener(this);
+ addKeyListener(this);
+ //addMouseWheelListener(this);
+
+ }
+ @Override
+ public void mouseClicked(MouseEvent mouseEvent) {
+ mouseX = mouseEvent.getX();
+ mouseY = mouseEvent.getY();
+ msg = "Mouse Clicked";
+ repaint();
+ }
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent){
+ mouseX = mouseEvent.getX();
+ mouseY = mouseEvent.getY();
+ msg = "Mouse Entered";
+ repaint();
+ }
+ @Override
+ public void mouseExited(MouseEvent mouseEvent){
+ mouseX = mouseEvent.getX();
+ mouseY = mouseEvent.getY();
+ msg = "Mouse Exited";
+ repaint();
+ }
+ @Override
+ public void mousePressed(MouseEvent mouseEvent){
+ mouseX = mouseEvent.getX();
+ mouseY = mouseEvent.getY();
+ msg = "Mouse Pressed Down";
+ repaint();
+ }
+ @Override
+ public void mouseReleased(MouseEvent mouseEvent){
+ mouseX = mouseEvent.getX();
+ mouseY = mouseEvent.getY();
+ msg = "Mouse Released Up";
+ repaint();
+ }
+ @Override
+ public void mouseDragged(MouseEvent mouseEvent){
+ mouseX = mouseEvent.getX();
+ mouseY = mouseEvent.getY();
+ msg = "**";
+ showStatus("Dragging Mouse at "+ mouseX +" " +mouseY);
+ repaint();
+ }
+ @Override
+ public void mouseMoved(MouseEvent mouseEvent){
+ showStatus("Moving Mouse at "+ mouseEvent.getX()+ " "+ mouseEvent.getY());
+ repaint();
+ }
+
+// public void mouseWheelMoved(MouseWheelListener mouseWheelListener){
+// showStatus("Wheel Rotation: "+ mouseWheelListener.getWheelRotation());
+// }
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode()==KeyEvent.VK_ENTER){
+ System.out.println("Hello");
+
+ JTextComponent nameInput = new JTextComponent(){};
+ JOptionPane.showMessageDialog(null , "You've Submitted the name " + nameInput.getText());
+ }
+
+ }
+ @Override
+ public void keyTyped(KeyEvent keyEvent){
+ int key = keyEvent.getKeyCode();
+
+ char ch = keyEvent.getKeyChar();
+ int id = keyEvent.getID();
+ int loc = keyEvent.getKeyLocation();
+ msg = "getKeyChar:"+ch +" | "+"getKeyCode:"+ key+" getID:"+ id + " | getKeyLocation:"+ loc;
+ showStatus( msg);
+
+ repaint();
+ }
+ @Override
+ public void keyReleased(KeyEvent keyEvent){
+
+ }
+
+ public void paint(Graphics graphics){
+ graphics.drawString(msg, mouseX, mouseY);
+ }
+}
diff --git a/src/MyFrame.java b/src/MyFrame.java
new file mode 100644
index 0000000..ea85701
--- /dev/null
+++ b/src/MyFrame.java
@@ -0,0 +1,66 @@
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.util.Locale;
+
+class MyFrame extends JFrame {
+ private JTextArea jTextArea;
+ private JLabel lbl;
+
+ public MyFrame() {
+ super();
+ this.getContentPane().setLayout(new CardLayout());
+ this.getInputContext().selectInputMethod(new Locale("ru")); // Russian
+
+ JFrame jFrame = new JFrame("Keyboard");
+ jFrame.setLayout(new BorderLayout());
+
+ lbl = new JLabel("Key: ");
+
+ jTextArea = new JTextArea(5, 20);
+ jFrame.add(jTextArea, BorderLayout.CENTER);
+
+ this.getContentPane().add(jTextArea, BorderLayout.CENTER);
+ this.getContentPane().add(lbl, BorderLayout.SOUTH);
+
+ addKeyListener(new KeyListener() {
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ lbl.setText("Key: " + e.getKeyChar()); // Show typed character
+
+
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+
+ }
+ });
+
+// {
+// public void keyPressed(KeyEvent e) {
+// lbl.setText("Key: " + e.getKeyChar()); // Show typed character
+// }
+// public void keyReleased(KeyEvent e) {}
+// public void keyTyped(KeyEvent e) {}
+// };
+
+
+ }
+ public static void main(String args[]){
+ MyFrame myFrame = new MyFrame();
+
+ myFrame.setSize(500,500);
+
+ myFrame.setVisible(true);
+
+ }
+
+
+}
diff --git a/src/NEw.java b/src/NEw.java
new file mode 100644
index 0000000..da95b8b
--- /dev/null
+++ b/src/NEw.java
@@ -0,0 +1,24 @@
+public class NEw {
+ public static void main(String args[]){
+ int[][] a={{1,2,3,4,5,6},{7,8,9,1,2,3},{4,5,6,7,8,9},{1,2,3,4,5,6},{7,8,9,1,2,3},{4,5,6,7,8,9,}};
+ int sum[][] = new int[6][6];
+ int i1=0,i2=0,i3=0,i4=2,i5=3,i6=3,i7=3;
+ int j1=0,j2=1,j3=2,j4=2,j5=0,j6=1,j7=2;
+ for(int r=0; r<4; r++){
+ for(int c=0; c<3; c++){
+ sum[r][c] = a[i1][j1]+ a[i2][j2]+ a[i3][j3] + a[i4][j4] +a[i5][j5]+a[i6][j6]+ a[i7][j7];
+ j1++;j2++;j3++;j4++;j5++;j6++;j7++;
+ }
+ i1++;i2++;i3++;i4++;i5++;i6++;i7++;
+ }
+ int max = sum[0][0];
+ for(int i=0;i<5; i++){
+ for (int j = 0; j < 20; j++) {
+ if(sum[i][j] > max){
+ max = sum[i][j];
+ }
+ }
+ }
+ System.out.println(max);
+ }
+}
diff --git a/src/PaintDemo.java b/src/PaintDemo.java
new file mode 100644
index 0000000..c8f0660
--- /dev/null
+++ b/src/PaintDemo.java
@@ -0,0 +1,63 @@
+import javax.swing.*;
+import java.awt.*;
+import java.util.Random;
+import java.awt.event.*;
+
+class PaintPanel extends JPanel{
+ Random random;
+ PaintPanel(){
+ setBorder(BorderFactory.createLineBorder(Color.cyan, 5));
+ random = new Random();
+ }
+ public void paintComponent(Graphics graphics){
+ super.paintComponent(graphics);
+ }
+ int x, y, x2, y2, i=1;
+ int height = getHeight();
+ int width = getWidth();
+
+// @Override
+// public Insets getInsets(Insets insets) {
+// return super.getInsets(insets);
+// }
+
+//
+// @Override
+// public Insets getInsets() {
+// return insets;
+// }
+ Insets insets = getInsets();
+ while(true){
+ x = random.nextInt(width - insets.left);
+ y = random.nextInt(height - insets.bottom);
+ x2 = random.nextInt(width - insets.right);
+ y2 = random.nextInt(height - insets.top);
+ graphics.drawLine(x, y, x2, y2);
+ }
+}
+public class PaintDemo {
+ JLabel jLabel;
+ PaintPanel paintPanel;
+ PaintDemo(){
+ JFrame jFrame = new JFrame("Paint Demo");
+ jFrame.setSize(200,150);
+ jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ paintPanel = new PaintPanel();
+
+ jFrame.add(paintPanel);
+ jFrame.setVisible(true);
+ }
+ public static void main(String args[]){
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new PaintDemo();
+ }
+ });
+
+ }
+
+
+}
diff --git a/src/Palindrome.java b/src/Palindrome.java
new file mode 100644
index 0000000..fd9b3fd
--- /dev/null
+++ b/src/Palindrome.java
@@ -0,0 +1,19 @@
+public class Palindrome {
+
+ public static void main(String ... args){
+ //public boolean check(int a) {
+ int a =344;
+ int rem=0, rev=0, temp =a;
+ boolean dic= false;
+ while(a != 0){
+ rem = a%10;
+ rev = rev*10 + rem;
+ a /=10;
+ }
+ if(temp == rev){
+ System.out.println("palindrome");
+ }else{ System.out.println(" not palindrome");
+ }
+ }
+
+}
diff --git a/src/PrimeChecker.java b/src/PrimeChecker.java
new file mode 100644
index 0000000..393e9ce
--- /dev/null
+++ b/src/PrimeChecker.java
@@ -0,0 +1,86 @@
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import java.math.*;
+import java.util.regex.*;
+import java.lang.reflect.*;
+import static java.io.InputStream.*;
+
+
+
+class Prime{
+ public void checkPrime(int ... varArgs) throws IOException{
+ int[] prime = new int[varArgs.length];
+ int j=0;
+
+ for(int x: varArgs){
+ int flag =1;
+ boolean dic = false;
+ if(x==1 || x==2 ){flag = 1;}
+ if(x < 0){flag = 0;}
+
+ for(int i =2; i < x/2; i++){
+ if(x%i == 0 ){flag =0;break;}
+ }
+ if(flag == 1){
+ prime[j] = x; j++;
+
+ }
+
+ for(int i=0; i set=new HashSet<>();
+ boolean overload=false;
+ for(int i=0;i=97|| n1<= 97+31){
+ n1-=32;
+ }
+ if(n2>=97|| n2<= 97+31){
+ n2 -= 32;
+ }
+
+
+ s1.setCharAt(0, (char)(n1));
+ s2.setCharAt(0, (char)(n2));
+
+ String a1 = new String(s1);
+ String a2 = new String(s2);
+
+ System.out.println(len+ "\nNo\n"+ a1 +" "+ a2);
+ }
+}
+
+
+
diff --git a/src/Solution1.java b/src/Solution1.java
new file mode 100644
index 0000000..fbf4861
--- /dev/null
+++ b/src/Solution1.java
@@ -0,0 +1,15 @@
+import java.util.Scanner;
+
+public class Solution1 {
+
+ public static void main(String[] args) {
+ Scanner in = new Scanner(System.in);
+ String S = in.next();
+ int start = in.nextInt();
+ int end = in.nextInt();
+
+ String sub = S.substring(start, end);
+ System.out.println(sub);
+ }
+}
+
diff --git a/src/Solution2.java b/src/Solution2.java
new file mode 100644
index 0000000..9c15223
--- /dev/null
+++ b/src/Solution2.java
@@ -0,0 +1,42 @@
+import java.util.Scanner;
+
+public class Solution2 {
+
+ public static String getSmallestAndLargest(String s, int k) {
+ String smallest = "";
+ String largest = "";
+ int len = s.length();
+ String word[] = new String[len-k-1];
+
+ for(int i=0; i< len-k-1;i++){
+ word[i] = s.substring(i, i+k);
+ }
+ for(int i =0; i 0){
+ String temp = word[i];
+ word[i] = word[j];
+ word[j]= temp;
+ }else if(val < 0){
+ String temp = word[j];
+ word[j] = word[i];
+ word[i]= temp;
+ }
+ }
+ }
+
+ return word[0] + "\n" + word[len-k-2];
+ }
+
+
+ public static void main(String[] args) {
+ Scanner scan = new Scanner(System.in);
+ String s = scan.next();
+ int k = scan.nextInt();
+ scan.close();
+
+ System.out.println(getSmallestAndLargest(s, k));
+ }
+}
diff --git a/src/SwingDemo.java b/src/SwingDemo.java
new file mode 100644
index 0000000..a8760ba
--- /dev/null
+++ b/src/SwingDemo.java
@@ -0,0 +1,43 @@
+import javax.swing.*;
+import java.awt.*;
+
+public class SwingDemo {
+
+
+ SwingDemo(){
+ JFrame jFrame = new JFrame("A simple swing application.");
+ Icon icon = new ImageIcon("C:\\Users\\zeeshan\\Pictures\\vlcsnap-2019-02-24-21h26m43s779.png");
+
+ jFrame.setSize(7750,1100);
+ //Frame frame = new Frame("Hello");
+ jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ JLabel jLabel = new JLabel("Swing means powerful GUI.");
+ jFrame.setVisible(true);
+
+ //progress bar
+ JProgressBar jProgressBar = new JProgressBar();
+
+ //JButton
+ JButton jButton = new JButton("Hello", icon);
+
+
+ //BorderLayout'
+ BorderLayout borderLayout = new BorderLayout(3,3);
+
+ jFrame.add(jLabel);
+ jFrame.add(jProgressBar);
+ jFrame.add(jButton);
+ jFrame.setIconImage(new ImageIcon("C:\\Users\\zeeshan\\Pictures\\vlcsnap-2019-02-24-21h26m43s779.png").getImage());
+
+ }
+
+
+ public static void main(String args[]){
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ new SwingDemo();
+ }
+ });
+ }
+}
diff --git a/src/VarArgsAddition.class b/src/VarArgsAddition.class
new file mode 100644
index 0000000..bb09f4e
Binary files /dev/null and b/src/VarArgsAddition.class differ
diff --git a/src/VarArgsAddition.java b/src/VarArgsAddition.java
new file mode 100644
index 0000000..bf9ed84
--- /dev/null
+++ b/src/VarArgsAddition.java
@@ -0,0 +1,87 @@
+/*
+* This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*
+* */
+
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+
+//Write your code here
+class Add{
+ void add(int ... varArgs){
+ int sum=0;
+ int j=0;
+ for(int i : varArgs){
+ sum += i;
+ if(j==0){
+ System.out.print(i);
+ j++;
+ }else {
+ System.out.print("+" + i);
+ }
+ }
+ System.out.println("="+sum);
+ }
+}
+
+public class VarArgsAddition {
+
+ public static void main(String[] args) {
+ try{
+ BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
+ int n1=Integer.parseInt(br.readLine());
+ int n2=Integer.parseInt(br.readLine());
+ int n3=Integer.parseInt(br.readLine());
+ int n4=Integer.parseInt(br.readLine());
+ int n5=Integer.parseInt(br.readLine());
+ int n6=Integer.parseInt(br.readLine());
+ Add ob=new Add();
+ ob.add(n1,n2);
+ ob.add(n1,n2,n3);
+ ob.add(n1,n2,n3,n4,n5);
+ ob.add(n1,n2,n3,n4,n5,n6);
+ Method[] methods=Add.class.getDeclaredMethods();
+ Set set=new HashSet<>();
+ boolean overload=false;
+ for(int i=0;i.
+*
+* **/
+
+
+
+
+// Name of the package must be same as the directory
+// under which this file is saved
+package myPackage;
+
+import java.util.Scanner;
+
+public class MyClass
+{
+ public void getNames(String s) {
+ Scanner scanner = new Scanner(System.in);
+
+
+ System.out.println(s + " "+ scanner.nextLine());
+ }
+}
\ No newline at end of file
diff --git a/src/myPackage/PrintName.java b/src/myPackage/PrintName.java
new file mode 100644
index 0000000..46d431e
--- /dev/null
+++ b/src/myPackage/PrintName.java
@@ -0,0 +1,34 @@
+/*
+* This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+* */
+
+
+/*import 'MyClass' class from 'names' mypackage */
+
+import myPackage.*;
+
+class PrintName {
+ public static void main(String ... args){
+ //initializing the string variable
+ //with a value
+ String name = "Geeks for Geeks " ;
+
+ //Creating an instance of MyClass in the package.
+
+ MyClass myClass = new MyClass();
+ myClass.getNames(name);
+ }
+
+
+}
diff --git a/src/try_catch.java b/src/try_catch.java
new file mode 100644
index 0000000..dd354c0
--- /dev/null
+++ b/src/try_catch.java
@@ -0,0 +1,42 @@
+import java.util.InputMismatchException;
+import java.util.Scanner;
+
+class try_catch {
+
+ public static void main(String[] args) {
+ /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
+ Scanner scanner = new Scanner(System.in);
+
+ try {
+ long n1 = scanner.nextLong();
+ long n2 = scanner.nextLong();
+ MyException me;
+ if(n1 > Math.pow(2, 31)-1 || n2 > Math.pow(2, 31)-1) {
+ throw me = new MyException("{-truncated-}");
+ callME(me);
+ }
+ long n3 = n1 / n2;
+ call(n3);
+
+ }
+ catch (ArithmeticException | InputMismatchException e) {
+ System.out.println(e);
+ }
+ }
+ static void call(long n){
+ System.out.println(n);
+ }
+ void callME(MyException m1){
+ catch (MyException e){
+ System.out.println(me.s);
+ }
+
+ }
+}
+class MyException extends Exception{
+ String s;
+ MyException(String s1){
+ s = s1;
+ }
+}
+