diff --git a/IndustrialTrainingProjects/PrivateConBasic.java b/IndustrialTrainingProjects/PrivateConBasic.java new file mode 100644 index 0000000..461cb29 --- /dev/null +++ b/IndustrialTrainingProjects/PrivateConBasic.java @@ -0,0 +1,13 @@ +// Program to implement private constructor using the basic method. + +package IndustrialTrainingProjects; + +public class PrivateConBasic { + public static void main(String[] args){ + PrivateConBasic obj=new PrivateConBasic("Hello"); + + } + private PrivateConBasic(String a){ + System.out.println(a); + } +} diff --git a/IndustrialTrainingProjects/PrivateConSingleton.java b/IndustrialTrainingProjects/PrivateConSingleton.java new file mode 100644 index 0000000..e88e848 --- /dev/null +++ b/IndustrialTrainingProjects/PrivateConSingleton.java @@ -0,0 +1,22 @@ +// Program to implement private constructor using the singleton method. + +package IndustrialTrainingProjects; + +public class PrivateConSingleton { + private PrivateConSingleton () { + System.out.println("This is a private constructor."); + } + + public static void instanceMethod() { + + PrivateConSingleton obj = new PrivateConSingleton(); + } + + } + + class Main { + + public static void main(String[] args) { + PrivateConSingleton.instanceMethod(); + } + } \ No newline at end of file diff --git a/IndustrialTrainingProjects/README.MD b/IndustrialTrainingProjects/README.MD new file mode 100644 index 0000000..5683965 --- /dev/null +++ b/IndustrialTrainingProjects/README.MD @@ -0,0 +1,25 @@ +## Introduction: + +Here are programs that every budding programmer who is learning to code in Java should start with. +These programs are a compilation of many different types of programs and levels of programming you should try. + +** These Codes are done during the Industrial Training Program. Any program you find here is taught during the +the training program. ** + +## Pre-Requisites: + +1. A coding IDE or just use the CMD/Terminal on your Windows Pc/Mac respectively (I used VS Code for this). + +2. Check that Java is properly installed in your system and the Path to Java is integratively set in your system. + +3. Start by trying to create the program by yourself if you encounter any problems refer to the code in the program file, +if the problem still persist then create a issue or use Google/Stack Overlflow for help. + +4. Done! You have successfully created the program in Java by your own. + +## Serial: + +|Serial No.|Program Name|Description of the program| +|----------|------------|--------------------------| +|1 | [PrivateConBasic.java](https://github.com/psavarmattas/Java-Projects/blob/master/IndustrialTrainingProjects/PrivateConBasic.java) | Program to implement private constructor using the basic method. | +|2 | [PrivateConSingleton.java](https://github.com/psavarmattas/Java-Projects/blob/master/IndustrialTrainingProjects/PrivateConSingleton.java) | Program to implement private constructor using the Singleton method. | \ No newline at end of file