├── Array.java ├── Array2.java ├── BreakApp.java ├── ContinueApp.java ├── ConversionExplicit.java ├── CreateDirectory.java ├── CreateFile.java ├── DBConnect.java ├── Demo.java ├── ExceptionDemo.java ├── ExceptionDemo2.java ├── ExceptionDemo3.java ├── ExceptionDemo4.java ├── ExceptionDemo5.java ├── Jagged.java ├── LabeledBreakApp.java ├── LabeledContinueApp.java ├── PathMethods.java ├── README.md ├── Shirt.java ├── Strings.java ├── ThrowsExecp.java ├── VariableApp.java ├── department.form ├── department.java └── test.java /Array.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class Array{ 11 | public static void main(String[] args) { 12 | int arr[] = {23,67,84,75,95,34,54,6,4,6,86}; 13 | System.out.println("Length: "+arr.length); 14 | System.out.println("Elements are:"); 15 | for (int i = arr.length-1 ;i >= 0 ; i--) 16 | { 17 | System.out.print(arr[i] + " "); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Array2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class Array2 { 11 | public static void main(String[] args) { 12 | int a[][] = new int[3][2]; 13 | a[0][0] = 56; 14 | a[0][1] = 74; 15 | a[1][0] = 88; 16 | a[1][1] = 34; 17 | a[2][0] = 24; 18 | a[2][1] = 43; 19 | for (int i = 0; i < 3 ; i ++){ 20 | for (int j = 0; j < 2 ; j ++){ 21 | System.out.print(a[i][j]+ " "); 22 | } System.out.println(); } 23 | }} 24 | 25 | 26 | -------------------------------------------------------------------------------- /BreakApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class BreakApp { 11 | public static void main (String args[]) 12 | { 13 | for(int count = 1;count<10;count++) { 14 | if(count ==5) 15 | break; //exit from the current loop 16 | System.out.println("Count is: " + count); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /ContinueApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class ContinueApp { 11 | public static void main (String args[]) { 12 | for(int count = 1;count<10;count++) { 13 | if(count ==5) 14 | continue; 15 | System.out.println("Count is: " + count); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ConversionExplicit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class ConversionExplicit { 11 | public static void main(String[] args) 12 | { 13 | double d = 100.04; 14 | long l = (long)d; //convert double into long 15 | int i = (int)l; // long convert into int 16 | System.out.println("Double value "+d); 17 | System.out.println("Long value "+l); 18 | System.out.println("Int value "+i); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CreateDirectory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | import java.nio.file.*; 11 | import java.io.*; 12 | 13 | public class CreateDirectory { 14 | public static void main(String args[]) { 15 | try { 16 | Path path = Paths.get("C:\\Users\\Sakthivel\\Documents\\valueaddedcourse\\SampleDirectory"); 17 | if (!Files.exists(path)) { 18 | Files.createDirectory(path); 19 | System.out.println("Directory created"); 20 | } else { 21 | System.out.println("Directory already exists"); 22 | } 23 | } catch (IOException e) { 24 | System.out.println(e); //Exception details 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CreateFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | import java.nio.file.*; 11 | import java.io.*; 12 | 13 | public class CreateFile { 14 | public static void main(String args[]) { 15 | try { 16 | Path path1 = Paths.get("C:\\Users\\Sakthivel\\Documents\\valueaddedcourse\\SampleDirectory\\Sample.txt"); 17 | if (!Files.exists(path1)) { 18 | Files.createFile(path1); 19 | System.out.println("File created"); 20 | } else { 21 | System.out.println("File already exists"); 22 | } 23 | } catch(IOException e) { 24 | System.out.println(e); // Exception details 25 | } 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /DBConnect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | package javatask; 6 | 7 | /** 8 | * 9 | * @author Sakthivel 10 | */ 11 | import java.sql.*; 12 | 13 | public class DBConnect { 14 | public static void main(String args[]) { 15 | try { 16 | // Step 1: Load the driver class 17 | Class.forName("com.mysql.cj.jdbc.Driver"); 18 | // Step 2: Create the connection object 19 | Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/department", "root", "Sakthivel@2903"); 20 | // Step 3: Create the statement object 21 | Statement stmt = con.createStatement(); 22 | 23 | // Step 4: Execute query 24 | // Uncomment the appropriate line(s) based on the operation you want to perform 25 | 26 | // Creating a table 27 | // stmt.executeUpdate("create table employee (empid int, empname varchar(255))"); 28 | 29 | // Inserting a record 30 | //stmt.executeUpdate("insert into dep_info values(3, 'CSE')"); 31 | 32 | // Updating a record 33 | //stmt.executeUpdate("update employee set empname='Aravind' where empid=120"); 34 | 35 | // Selecting records 36 | ResultSet rs = stmt.executeQuery("select * from dep_info"); 37 | while(rs.next()) 38 | System.out.println(rs.getInt(1)+" "+rs.getString(2)); 39 | // Deleting records 40 | stmt.executeUpdate("delete from dep_info where dep_code='3'"); 41 | 42 | // Step 5: Close the connection object 43 | con.close(); 44 | } catch (Exception e) { 45 | System.out.println(e); 46 | } 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Demo.java: -------------------------------------------------------------------------------- 1 | class Clothing{ 2 | private float cost; 3 | 4 | public float getCost() { 5 | return cost; 6 | } 7 | 8 | public void setCost(float cost) { 9 | this.cost = cost; 10 | } 11 | } 12 | 13 | public class Demo extends Clothing { 14 | private int _neckSize; 15 | public int getNeckSize(){ 16 | return _neckSize; 17 | } 18 | public void setNeckSize(int nSize){ 19 | this._neckSize = nSize; 20 | } 21 | 22 | public static void main(String [] args){ 23 | Demo de = new Demo(); 24 | de.setCost(350); 25 | System.out.println(de.getCost()); 26 | 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ExceptionDemo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class ExceptionDemo { 11 | public static void main(String args[]){ 12 | try{ 13 | int a[]=new int[5]; 14 | a[5]=30/0; 15 | } 16 | catch(ArithmeticException e){ 17 | System.out.println(e); 18 | } 19 | catch(ArrayIndexOutOfBoundsException e) { 20 | System.out.println(e); } 21 | catch(Exception e) 22 | { 23 | System.out.println(e); } 24 | System.out.println("rest of the code..."); 25 | } 26 | } 27 | 28 | 29 | -------------------------------------------------------------------------------- /ExceptionDemo2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class ExceptionDemo2 { 11 | static void validate(int num){ 12 | if(num<0) 13 | throw new ArithmeticException("Invalid value"); 14 | else 15 | System.out.println("Valid to proceed"); 16 | } 17 | public static void main(String args[]){ 18 | try{ 19 | validate(-10); 20 | } 21 | catch(Exception e){ 22 | System.out.println("Error:"+e); 23 | } 24 | System.out.println("rest of the code..."); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /ExceptionDemo3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class ExceptionDemo3 { 11 | static void fun() throws IllegalAccessException { 12 | System.out.println("Inside fun(). "); 13 | throw new IllegalAccessException("demo"); 14 | } 15 | public static void main(String args[]) { 16 | try{ 17 | fun(); 18 | } 19 | catch(IllegalAccessException e){ 20 | System.out.println("caught in main."); 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /ExceptionDemo4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class ExceptionDemo4 { 11 | public static void main(String args[]) { 12 | try { 13 | int data=25/5; 14 | System.out.println(data); 15 | } 16 | catch(NullPointerException e) { 17 | System.out.println(e); 18 | } 19 | finally { 20 | System.out.println("finally block is always executed"); 21 | } 22 | System.out.println("rest of the code..."); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /ExceptionDemo5.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | class InvalidAgeException extends Exception { 11 | InvalidAgeException(String s) { 12 | // Call constructor of parent Exception 13 | super(s); 14 | } 15 | } 16 | public class ExceptionDemo5 { 17 | static void validate(int age) throws InvalidAgeException { 18 | if(age<18) 19 | throw new InvalidAgeException("not eligible"); 20 | else 21 | System.out.println("Eligible"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Jagged.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class Jagged { 11 | public static void main(String[] args) { 12 | // Declaring 2-D array with 4 rows 13 | int arr[][] = new int[4][]; 14 | // Making the above array Jagged 15 | // First row has 3 columns 16 | arr[0] = new int[3]; 17 | // Second row has 2 columns 18 | arr[1] = new int[2]; 19 | arr[2] = new int[1]; 20 | arr[3] = new int[4]; 21 | // Initializing array 22 | int count = 5; 23 | for (int i = 0; i < arr.length; i++) 24 | for (int j = 0; j < arr[i].length; j++) { 25 | arr[i][j] = count; 26 | count+=5; 27 | } 28 | // Displaying the values of 2D Jagged array 29 | System.out.println("Contents of 2D Jagged Array"); 30 | for (int i = 0; i < arr.length; i++) { 31 | for (int j = 0; j < arr[i].length; j++) 32 | System.out.print(arr[i][j] + " "); 33 | System.out.println(); 34 | } 35 | } 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /LabeledBreakApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class LabeledBreakApp { 11 | public static void main(String args[]){ 12 | first: 13 | for (int i = 0; i < 3; i++) { 14 | second: 15 | for (int j = 0; j < 3; j++) { 16 | if (1== i && 1 == j) { 17 | break first; 18 | } 19 | System.out.println(i + " " + j); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LabeledContinueApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class LabeledContinueApp { 11 | public static void main(String args[]){ 12 | first: 13 | for (int i = 0 ; i < 3; i++) { 14 | second: 15 | for (int j = 0; j < 3; j++) { 16 | if (1 == i && 1 == j) { 17 | continue second; 18 | } 19 | System.out.println(i + " " + j); 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /PathMethods.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | import java.nio.file.Path; 11 | import java.nio.file.Paths; 12 | public class PathMethods { 13 | public static void main(String args[]) { 14 | Path p1 = Paths.get ("C:\\Users\\Sakthivel\\Documents\\valueaddedcourse\\Programs\\26. File Path"); 15 | Path normalizedPath = p1.normalize(); 16 | var p2 = Paths.get ("C:\\Users\\Sakthivel\\Documents\\valueaddedcourse\\Programs\\26. File Path"); 17 | System.out.println("NormalizedPath: "+ normalizedPath); 18 | Path subPath = p1.subpath (1, 3); 19 | System.out.println("SubPath: "+ subPath); 20 | System.out.println("getFileName: "+ p1.getFileName()); 21 | System.out.println("getParent: "+p1.getParent()); 22 | System.out.println("getNameCount: "+p1.getNameCount()); 23 | System.out.println("getRoot: " + p1.getRoot()); 24 | System.out.println("isAbsolute: "+p1.isAbsolute()); 25 | System.out.println("toAbsolutePath: "+p1.toAbsolutePath()); 26 | System.out.println("toURI: "+p1.toUri()); 27 | if(p1.equals(p2)) 28 | System.out.println("Both are equal"); 29 | else 30 | System.out.println("Both are not equal"); 31 | } 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # java-fundamentals -------------------------------------------------------------------------------- /Shirt.java: -------------------------------------------------------------------------------- 1 | public class Shirt extends Clothing { 2 | private int _neckSize; 3 | public int getNeckSize(){ 4 | return _neckSize; 5 | } 6 | public void setNeckSize(int nSize){ 7 | this.neckSize = nSize; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Strings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class Strings { 11 | public static void main(String[] args) { 12 | System.out.println("Vy Technical Carrer Development Center"); 13 | System.out.println("Length = "+"VyTCDC".length()); 14 | System.out.println("Vy".concat("TcDc")); 15 | System.out.println("Vy Technical Carrer".substring(3, 12)); 16 | System.out.println("Vy".toUpperCase()); 17 | System.out.println("Vy".toLowerCase()); 18 | System.out.println(" Vy TCDC ".trim()); 19 | System.out.println("Vy".equals("Vy")); 20 | System.out.println("Vy".equals("VY")); 21 | System.out.println("Vy".equalsIgnoreCase("VY")); 22 | System.out.println("VyTCDC".startsWith("Vy")); 23 | System.out.println("VyTCDC".endsWith("dc")); 24 | System.out.println("VyTCDC".toCharArray()); } 25 | } 26 | -------------------------------------------------------------------------------- /ThrowsExecp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class ThrowsExecp { 11 | public static void main(String args[]){ 12 | try{ 13 | String str = null; 14 | System.out.println(str.length()); 15 | } 16 | catch(NullPointerException e){ 17 | System.out.println(e); 18 | } 19 | System.out.println("rest of the code"); 20 | } 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /VariableApp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template 4 | */ 5 | 6 | /** 7 | * 8 | * @author Sakthivel 9 | */ 10 | public class VariableApp { 11 | int mark = 95 ;//instance variable 12 | static char grade = 'S'; // static variable 13 | public static void main(String[] args) 14 | { 15 | float average=95.0f; 16 | System.out.println(average);// local variable 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /department.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
200 | -------------------------------------------------------------------------------- /department.java: -------------------------------------------------------------------------------- 1 | package javatask; 2 | import java.sql.*; 3 | import jav.io.*; 4 | import javax.swing.table.DefaultTableModel; 5 | 6 | /* 7 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license 8 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template 9 | */ 10 | 11 | /** 12 | * 13 | * @author Sakthivel 14 | */ 15 | public class department extends javax.swing.JFrame { 16 | 17 | /** 18 | * Creates new form department 19 | */ 20 | public department() { 21 | initComponents(); 22 | } 23 | 24 | /** 25 | * This method is called from within the constructor to initialize the form. 26 | * WARNING: Do NOT modify this code. The content of this method is always 27 | * regenerated by the Form Editor. 28 | */ 29 | @SuppressWarnings("unchecked") 30 | //