├── Ecommerce ├── .gitignore ├── .idea │ ├── .gitignore │ ├── misc.xml │ ├── modules.xml │ └── uiDesigner.xml ├── Ecommerce.iml └── src │ └── ecommerce │ ├── CreditCard.java │ ├── Customer.java │ ├── Main.java │ ├── Product.java │ └── ShoppingCart.java ├── FirstSeleniumScript ├── .gitignore ├── .idea │ ├── .gitignore │ ├── encodings.xml │ └── misc.xml ├── Drivers │ ├── chromedriver.exe │ ├── geckodriver.exe │ └── msedgedriver.exe ├── pom.xml └── src │ ├── main │ └── java │ │ └── FirstSeleniumScript │ │ └── Main.java │ └── test │ └── java │ └── MyfirstTest │ └── FirstDemo.java ├── OOPbasic ├── .gitignore ├── .idea │ ├── .gitignore │ ├── misc.xml │ ├── modules.xml │ ├── uiDesigner.xml │ └── vcs.xml ├── OOPbasic.iml └── src │ ├── Abstractions │ ├── Karim.java │ ├── Main.java │ ├── MobileUser.java │ └── Rahim.java │ ├── Abstracts │ ├── Animal.java │ ├── Lion.java │ ├── Tiger.java │ ├── Zoo.java │ └── ZooDemo.java │ ├── Collectionframework │ ├── ListDemo.java │ ├── ListWihVector.java │ └── StackDemo.java │ ├── Generics2 │ ├── Tuple.java │ └── TupleDemo.java │ ├── GenericsDynamicArr │ ├── DynamicArray.java │ └── DynamicArrayDemo.java │ ├── Genericss │ ├── Generic.java │ └── GenericClassDemo.java │ ├── InheritenceA │ ├── Animal.java │ ├── Cat.java │ ├── Coco.java │ └── Main.java │ ├── OOPs │ ├── Bicycle.java │ ├── EnumExamp.java │ ├── Main.java │ ├── MthodOverload.java │ └── StudentMarks.java │ ├── Polymorphism │ ├── Coffee.java │ ├── Cup.java │ ├── Liquid.java │ ├── Main.java │ └── Milk.java │ ├── Polymorphism2 │ ├── Circle.java │ ├── DrawingDemo.java │ ├── DrawingPad.java │ ├── Shape.java │ └── Square.java │ ├── PostAbstract │ ├── Client.java │ ├── FixedPayCalculator.java │ ├── HourlyPayCalculator.java │ ├── HrManager.java │ ├── Main.java │ └── PayCalculator.java │ ├── PreAbstract │ ├── Client.java │ ├── HrManager.java │ ├── Main.java │ └── PayCalculator.java │ ├── Set │ ├── HashSetExp.java │ ├── LinkedHashExp.java │ └── TreeSetExp.java │ ├── interface1 │ ├── BkashPayment.java │ ├── CashPayment.java │ ├── Payment.java │ ├── PaymentDemo.java │ └── PaymentEngine.java │ └── interface2samePostAbstract │ ├── Client.java │ ├── FixedPayCalculator.java │ ├── HourlyPayCalculator.java │ ├── HrManager.java │ ├── Main.java │ └── PayCalculator.java ├── ProblemSolving ├── .gitignore ├── .idea │ ├── .gitignore │ ├── misc.xml │ ├── modules.xml │ └── uiDesigner.xml ├── ProblemSolving.iml └── src │ └── ProblemSolving │ ├── Main.java │ └── StringToCharCount.java ├── Testing ├── .gitignore ├── .idea │ ├── .gitignore │ ├── encodings.xml │ └── misc.xml ├── Drivers │ └── chromedriver.exe ├── pom.xml └── src │ ├── main │ └── java │ │ └── Testing │ │ └── Main.java │ └── test │ └── java │ └── Test │ └── Demo1.java └── helloworld ├── .gitignore ├── .idea ├── .gitignore ├── misc.xml ├── modules.xml └── uiDesigner.xml ├── JavaBasics.iml └── src └── JavaBasics ├── Array2.java ├── ArrayPrint.java ├── ArrayToStr.java ├── Arre.java ├── AsciiTable.java ├── DecimalToHexBiOctal.java ├── Dr.java ├── FnBracketBalanceChecker.java ├── IntFloating.java ├── JavaToASCII.java ├── Main.java ├── Mathmatian.java ├── MaxValue.java ├── Numeric.java ├── StringJoinerExp.java ├── TextBlock.java ├── TwoDimentionalArr.java ├── eof.java ├── forEachLoop.java ├── horseshoe.java ├── input.java ├── loop.java ├── overflowUnderflow.java ├── print.java ├── twoNumberCompare.java └── typeCasting.java /Ecommerce/.gitignore: -------------------------------------------------------------------------------- 1 | ### IntelliJ IDEA ### 2 | out/ 3 | !**/src/main/**/out/ 4 | !**/src/test/**/out/ 5 | 6 | ### Eclipse ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | bin/ 15 | !**/src/main/**/bin/ 16 | !**/src/test/**/bin/ 17 | 18 | ### NetBeans ### 19 | /nbproject/private/ 20 | /nbbuild/ 21 | /dist/ 22 | /nbdist/ 23 | /.nb-gradle/ 24 | 25 | ### VS Code ### 26 | .vscode/ 27 | 28 | ### Mac OS ### 29 | .DS_Store -------------------------------------------------------------------------------- /Ecommerce/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /Ecommerce/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Ecommerce/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Ecommerce/.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /Ecommerce/Ecommerce.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Ecommerce/src/ecommerce/CreditCard.java: -------------------------------------------------------------------------------- 1 | package ecommerce; 2 | 3 | public class CreditCard { 4 | private final long number; 5 | private final int cvv; 6 | private final String validThroug; 7 | 8 | public CreditCard(long number, int cvv, String validThroug) 9 | { 10 | this.number = number; 11 | this.cvv = cvv; 12 | this.validThroug = validThroug; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Ecommerce/src/ecommerce/Customer.java: -------------------------------------------------------------------------------- 1 | package ecommerce; 2 | 3 | import ecommerce.CreditCard; 4 | 5 | public class Customer { 6 | private String name; 7 | private CreditCard creditCard; 8 | 9 | public Customer(String name, long number, int cvv, String validThrough){ 10 | this.name = name; 11 | this.creditCard = new CreditCard(number, cvv, validThrough); 12 | } 13 | 14 | public Customer(String name, CreditCard creditCard) 15 | { 16 | this.name = name; 17 | this.creditCard = creditCard; 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Ecommerce/src/ecommerce/Main.java: -------------------------------------------------------------------------------- 1 | package ecommerce; 2 | 3 | public class Main { 4 | 5 | public static void main(String [] args){ 6 | ShoppingCart shoppingCart = new ShoppingCart(); 7 | Product hp = new Product("Laptop Hp", 2500); 8 | Product dell = new Product("Laptop Dell", 3500); 9 | 10 | shoppingCart.addProduct(hp); // Call addProduct method on the shoppingCart instance 11 | shoppingCart.addProduct(dell); // Call addProduct method on the shoppingCart instance 12 | 13 | int totalPrice = shoppingCart.getTotalPrice(); 14 | System.out.println("ShoppingCart = "+ shoppingCart); 15 | System.out.println("Total Price = "+ totalPrice); 16 | } 17 | 18 | 19 | 20 | } -------------------------------------------------------------------------------- /Ecommerce/src/ecommerce/Product.java: -------------------------------------------------------------------------------- 1 | package ecommerce; 2 | 3 | public class Product { 4 | private final String name; 5 | private int price; 6 | 7 | public Product(String name, int price) 8 | { 9 | this.name = name; 10 | this.price = price; 11 | } 12 | 13 | public int getPrice(){ 14 | return this.price; 15 | } 16 | 17 | @java.lang.Override 18 | public String toString() { 19 | return "Product{" + 20 | "name='" + name + '\'' + 21 | ", price=" + price + 22 | '}'; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Ecommerce/src/ecommerce/ShoppingCart.java: -------------------------------------------------------------------------------- 1 | package ecommerce; 2 | 3 | import java.util.ArrayList; 4 | public class ShoppingCart { 5 | private ArrayList products = new ArrayList<>(); 6 | 7 | public void addProduct(Product product){ 8 | products.add(product); 9 | } 10 | 11 | public int getTotalPrice(){ 12 | int totalPrice = 0; 13 | for(Product product : products){ 14 | totalPrice += product.getPrice(); 15 | } 16 | return totalPrice; 17 | } 18 | 19 | @java.lang.Override 20 | public String toString() { 21 | return "ShoppingCart{" + 22 | "products=" + products + 23 | '}'; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /FirstSeleniumScript/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /FirstSeleniumScript/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /FirstSeleniumScript/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /FirstSeleniumScript/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /FirstSeleniumScript/Drivers/chromedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdruhulkuddus/java-learning/1751b485cf8ccf321210fc24297cce0413d08106/FirstSeleniumScript/Drivers/chromedriver.exe -------------------------------------------------------------------------------- /FirstSeleniumScript/Drivers/geckodriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdruhulkuddus/java-learning/1751b485cf8ccf321210fc24297cce0413d08106/FirstSeleniumScript/Drivers/geckodriver.exe -------------------------------------------------------------------------------- /FirstSeleniumScript/Drivers/msedgedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdruhulkuddus/java-learning/1751b485cf8ccf321210fc24297cce0413d08106/FirstSeleniumScript/Drivers/msedgedriver.exe -------------------------------------------------------------------------------- /FirstSeleniumScript/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | FirstSeleniumScript 8 | FirstSeleniumScript 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 17 13 | 17 14 | UTF-8 15 | 16 | 17 | 18 | org.seleniumhq.selenium 19 | selenium-java 20 | 4.18.1 21 | 22 | 23 | -------------------------------------------------------------------------------- /FirstSeleniumScript/src/main/java/FirstSeleniumScript/Main.java: -------------------------------------------------------------------------------- 1 | package FirstSeleniumScript; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /FirstSeleniumScript/src/test/java/MyfirstTest/FirstDemo.java: -------------------------------------------------------------------------------- 1 | package MyfirstTest; 2 | 3 | import org.openqa.selenium.By; 4 | import org.openqa.selenium.WebDriver; 5 | import org.openqa.selenium.chrome.ChromeDriver; 6 | import org.openqa.selenium.edge.EdgeDriver; 7 | import org.openqa.selenium.firefox.FirefoxDriver; 8 | 9 | public class FirstDemo { 10 | public static void main(String[] args) throws InterruptedException { 11 | // //chrome 12 | System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "//Drivers//chromedriver.exe"); 13 | WebDriver driver = new ChromeDriver(); 14 | driver.manage().window().maximize(); 15 | driver.get("https://opensource-demo.orangehrmlive.com/"); 16 | 17 | // firefox 18 | // System.setProperty("webdriver.gecko.driver", "F:\\JavaLearning\\FirstSeleniumScript\\Drivers\\geckodriver.exe"); 19 | // WebDriver driver = new FirefoxDriver(); 20 | // driver.get("https://opensource-demo.orangehrmlive.com/"); 21 | // 22 | // edge 23 | // System.setProperty("webdriver.edge.driver", System.getProperty("user.dir")+"//Drivers//msedgedriver.exe"); 24 | // WebDriver driver = new EdgeDriver(); 25 | // driver.manage().window().maximize(); 26 | // driver.get("https://opensource-demo.orangehrmlive.com/"); 27 | Thread.sleep(3000); 28 | // driver.close(); 29 | driver.findElement(By.name("username")).sendKeys("Admin"); 30 | driver.findElement(By.name("password")).sendKeys("admin123"); 31 | 32 | // driver.findElement(By.xpath("//button[@type=\"submit\"]")).click(); 33 | 34 | driver.findElement(By.xpath("//p[@class=\"oxd-text oxd-text--p orangehrm-login-forgot-header\"]")).click(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /OOPbasic/.gitignore: -------------------------------------------------------------------------------- 1 | ### IntelliJ IDEA ### 2 | out/ 3 | !**/src/main/**/out/ 4 | !**/src/test/**/out/ 5 | 6 | ### Eclipse ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | bin/ 15 | !**/src/main/**/bin/ 16 | !**/src/test/**/bin/ 17 | 18 | ### NetBeans ### 19 | /nbproject/private/ 20 | /nbbuild/ 21 | /dist/ 22 | /nbdist/ 23 | /.nb-gradle/ 24 | 25 | ### VS Code ### 26 | .vscode/ 27 | 28 | ### Mac OS ### 29 | .DS_Store -------------------------------------------------------------------------------- /OOPbasic/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /OOPbasic/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /OOPbasic/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OOPbasic/.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /OOPbasic/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /OOPbasic/OOPbasic.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /OOPbasic/src/Abstractions/Karim.java: -------------------------------------------------------------------------------- 1 | package Abstractions; 2 | 3 | public class Karim extends MobileUser{ 4 | 5 | // call(), sendMessage() 6 | @Override 7 | void sendMessage() { 8 | System.out.println("Hi, Im Karim"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OOPbasic/src/Abstractions/Main.java: -------------------------------------------------------------------------------- 1 | package Abstractions; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | MobileUser mobileUser; // mobileUser is reference 6 | 7 | mobileUser = new Rahim(); 8 | mobileUser.sendMessage(); 9 | mobileUser.call(); 10 | mobileUser = new Karim(); 11 | mobileUser.sendMessage(); 12 | 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OOPbasic/src/Abstractions/MobileUser.java: -------------------------------------------------------------------------------- 1 | package Abstractions; 2 | 3 | public abstract class MobileUser { 4 | 5 | void call(){ // non abstract 6 | System.out.println("Call Method"); 7 | } 8 | abstract void sendMessage(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /OOPbasic/src/Abstractions/Rahim.java: -------------------------------------------------------------------------------- 1 | package Abstractions; 2 | 3 | public class Rahim extends MobileUser { 4 | // call(), sendMessage() 5 | @Override 6 | void sendMessage() { 7 | System.out.println("Hi, I'm Rahim"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /OOPbasic/src/Abstracts/Animal.java: -------------------------------------------------------------------------------- 1 | package Abstracts; 2 | 3 | public abstract class Animal { 4 | private final int legs; 5 | private String name; 6 | 7 | public Animal(int legs, String name){ 8 | this.legs = legs; 9 | this.name = name; 10 | } 11 | 12 | public abstract String getDiets(); 13 | 14 | @Override 15 | public String toString(){ 16 | return (name + " has " + legs + " legs(s)"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OOPbasic/src/Abstracts/Lion.java: -------------------------------------------------------------------------------- 1 | package Abstracts; 2 | 3 | public class Lion extends Animal{ 4 | public Lion(){ 5 | super(4, "Lion"); 6 | } 7 | @Override 8 | public String getDiets(){ 9 | return "Meats"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /OOPbasic/src/Abstracts/Tiger.java: -------------------------------------------------------------------------------- 1 | package Abstracts; 2 | 3 | public class Tiger extends Animal{ 4 | public Tiger(){ 5 | super(4+4, "Tiger"); 6 | } 7 | @Override 8 | public String getDiets(){ 9 | return "Deers"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /OOPbasic/src/Abstracts/Zoo.java: -------------------------------------------------------------------------------- 1 | package Abstracts; 2 | 3 | public class Zoo { 4 | private Animal[] animals; // animal type array 5 | public Zoo(Animal[] animals) 6 | { 7 | this.animals = animals; 8 | } 9 | public void printInfo(){ 10 | for (Animal animal : animals) 11 | { 12 | System.out.println(animal.toString()); 13 | System.out.println("Diet: "+ animal.getDiets()); 14 | 15 | } 16 | } 17 | } 18 | 19 | 20 | /** 21 | * if(animal instanceof Lion){ 22 | * Lion lion = (Lion) animal; // Explicit downcasting from Animal to Lion 23 | * System.out.println("Diet of lion "+ lion.getDiets() ); 24 | * } else if (animal instanceof Tiger) { 25 | * Tiger tiger = (Tiger) animal; 26 | * System.out.println("Diet of tiger "+ tiger.getDiets() ); 27 | * } 28 | */ -------------------------------------------------------------------------------- /OOPbasic/src/Abstracts/ZooDemo.java: -------------------------------------------------------------------------------- 1 | package Abstracts; 2 | 3 | public class ZooDemo { 4 | public static void main(String[] args) { 5 | Animal[] animals = new Animal[3]; 6 | animals[0] = new Tiger(); // Implicit upcasting from Tiger to Animal 7 | animals[1] = new Lion(); 8 | animals[2] = new Tiger(); 9 | Zoo zoo = new Zoo(animals); 10 | zoo.printInfo(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OOPbasic/src/Collectionframework/ListDemo.java: -------------------------------------------------------------------------------- 1 | package Collectionframework; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class ListDemo { 7 | public static void main(String[] args) { 8 | List topCities = new ArrayList<>(); 9 | topCities.add("RUhUl"); 10 | topCities.add("Kuddus"); 11 | topCities.add("Feni"); 12 | 13 | System.out.println(topCities); 14 | 15 | int sizw = topCities.size(); 16 | System.out.println(sizw); 17 | 18 | topCities.remove(2); 19 | for (String s:topCities){ 20 | System.out.println(s); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /OOPbasic/src/Collectionframework/ListWihVector.java: -------------------------------------------------------------------------------- 1 | package Collectionframework; 2 | 3 | import java.util.List; 4 | import java.util.Vector; 5 | 6 | public class ListWihVector { 7 | public static void main(String[] args) { 8 | List topCities = new Vector<>(); 9 | topCities.add("RUhUl"); 10 | topCities.add("Kuddus"); 11 | topCities.add("Feni"); 12 | 13 | System.out.println(topCities); 14 | 15 | int sizw = topCities.size(); 16 | System.out.println(sizw); 17 | 18 | topCities.remove(2); 19 | for (String s:topCities){ 20 | System.out.println(s); 21 | } 22 | } 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /OOPbasic/src/Collectionframework/StackDemo.java: -------------------------------------------------------------------------------- 1 | package Collectionframework; 2 | 3 | import java.util.Stack; 4 | 5 | public class StackDemo { 6 | public static void main(String[] args) { 7 | String[] brackets = { 8 | "()[])", "(()[])", "()()", "[[" 9 | }; 10 | 11 | for (String exp:brackets){ 12 | String balanceStatus = isBalanced(exp) ? "Balanced" : "Not Balanced"; 13 | System.out.println(exp + " == " +balanceStatus); 14 | } 15 | } 16 | 17 | public static boolean isBalanced(String exp){ 18 | Stack characters = new Stack<>(); 19 | for (char bracket : exp.toCharArray()){ 20 | if(bracket == '[' || bracket == '{' || bracket == '('){ 21 | characters.push(bracket); 22 | } else if (characters.isEmpty()) { // empty and isEmpty is Same 23 | return false; 24 | } else if(bracket == ']' && characters.peek() == '['){ 25 | characters.pop(); 26 | } 27 | else if(bracket == ')' && characters.peek() == '('){ 28 | characters.pop(); 29 | } 30 | else if(bracket == '}' && characters.peek() == '{'){ 31 | characters.pop(); 32 | } 33 | else{ 34 | System.out.println(bracket + " eta "); 35 | return false; 36 | } 37 | } 38 | return characters.empty(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /OOPbasic/src/Generics2/Tuple.java: -------------------------------------------------------------------------------- 1 | package Generics2; 2 | 3 | public class Tuple { 4 | private final X x; 5 | private final Y y; 6 | 7 | public Tuple(X x, Y y){ 8 | this.x = x; 9 | this.y = y; 10 | } 11 | 12 | public X getX(){ 13 | return x; 14 | } 15 | 16 | public Y getY() { 17 | return y; 18 | } 19 | public void showTypes(){ 20 | System.out.println("Types of X is " + x.getClass().getName() + " and Value: "+ x); 21 | System.out.println("Types of Y is "+y.getClass().getName() + " and Value: "+y); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /OOPbasic/src/Generics2/TupleDemo.java: -------------------------------------------------------------------------------- 1 | package Generics2; 2 | 3 | public class TupleDemo { 4 | public static void main(String[] args) { 5 | Tuple tuple = new Tuple<>("Ruhul", "Kuddus"); 6 | tuple.showTypes(); 7 | Tuple person = new Tuple<>("Nafis", 45); 8 | person.showTypes(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OOPbasic/src/GenericsDynamicArr/DynamicArray.java: -------------------------------------------------------------------------------- 1 | package GenericsDynamicArr; 2 | 3 | import java.util.Arrays; 4 | import java.util.StringJoiner; 5 | 6 | public class DynamicArray { 7 | private static final int DEFAULT_CAPACITY = 10; 8 | 9 | private T[] elements; 10 | private int size; 11 | 12 | public DynamicArray() 13 | { 14 | elements = (T[]) new Object[DEFAULT_CAPACITY]; 15 | } 16 | public int size(){ 17 | return size; 18 | } 19 | public boolean isEmpty(){ 20 | return size == 0; 21 | } 22 | public void add(T item){ 23 | if(size == elements.length){ 24 | grow(); 25 | } 26 | elements[size] = item; 27 | size++; 28 | } 29 | private void grow(){ 30 | int newCapacity = elements.length * 2; 31 | elements = Arrays.copyOf(elements, newCapacity); 32 | } 33 | public T get(int index){ 34 | if(index < 0 || index >= size){ 35 | throw new IndexOutOfBoundsException(); 36 | } 37 | return elements[index]; 38 | } 39 | 40 | @Override 41 | public String toString(){ 42 | StringJoiner joiner = new StringJoiner(", "); 43 | for (int i = 0; i < size; i++){ 44 | T element = elements[i]; 45 | joiner.add(String.valueOf(element)); 46 | } 47 | return joiner.toString(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /OOPbasic/src/GenericsDynamicArr/DynamicArrayDemo.java: -------------------------------------------------------------------------------- 1 | package GenericsDynamicArr; 2 | 3 | public class DynamicArrayDemo { 4 | public static void main(String[] args) { 5 | DynamicArray numbers = new DynamicArray<>(); 6 | numbers.add(1); 7 | numbers.add(2); 8 | numbers.add(3); 9 | 10 | System.out.println(numbers); 11 | System.out.println(numbers.get(0)); 12 | System.out.println(numbers.get(1)); 13 | int totalElements = numbers.size(); 14 | System.out.println("Total elements = "+ totalElements); 15 | 16 | DynamicArray cities = new DynamicArray<>(); 17 | cities.add("Dhaka"); 18 | cities.add("Feni"); 19 | 20 | System.out.println(cities); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OOPbasic/src/Genericss/Generic.java: -------------------------------------------------------------------------------- 1 | package Genericss; 2 | 3 | public class Generic { 4 | private T obj; 5 | public Generic(T obj){ 6 | this.obj = obj; 7 | } 8 | 9 | public T getObj(){ 10 | return obj; 11 | } 12 | 13 | public void showType(){ 14 | System.out.println("Type of T: " + obj.getClass().getName()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OOPbasic/src/Genericss/GenericClassDemo.java: -------------------------------------------------------------------------------- 1 | package Genericss; 2 | 3 | public class GenericClassDemo { 4 | public static void main(String[] args) { 5 | Generic iObj; 6 | iObj = new Generic<>(88); 7 | iObj.showType(); 8 | 9 | int value = iObj.getObj(); 10 | System.out.println("Value = " + value); 11 | 12 | Generic strObj = new Generic<>("This is a test"); 13 | strObj.showType(); 14 | String strValue = strObj.getObj(); 15 | System.out.println("strValue = " + strValue); 16 | 17 | Generic floatValue= new Generic(5.50); 18 | floatValue.showType(); 19 | System.out.println("float vlue is = "+ floatValue.getObj()); 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OOPbasic/src/InheritenceA/Animal.java: -------------------------------------------------------------------------------- 1 | package InheritenceA; 2 | 3 | public class Animal { 4 | 5 | public void eat(){ 6 | System.out.println("Eat now"); 7 | } 8 | public void sleep(){ 9 | System.out.println("Sleep now"); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /OOPbasic/src/InheritenceA/Cat.java: -------------------------------------------------------------------------------- 1 | package InheritenceA; 2 | 3 | public class Cat extends Animal { 4 | public void makeSound(){ 5 | System.out.println("Meow meow"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /OOPbasic/src/InheritenceA/Coco.java: -------------------------------------------------------------------------------- 1 | package InheritenceA; 2 | 3 | public class Coco extends Animal{ 4 | public void moo(){ 5 | System.out.println("Moo Moo"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /OOPbasic/src/InheritenceA/Main.java: -------------------------------------------------------------------------------- 1 | package InheritenceA; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | Cat cat = new Cat(); 6 | cat.eat(); 7 | cat.sleep(); 8 | cat.makeSound(); 9 | Coco coco = new Coco(); 10 | coco.moo(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OOPbasic/src/OOPs/Bicycle.java: -------------------------------------------------------------------------------- 1 | package OOPs; 2 | 3 | public class Bicycle { 4 | private int speed = 0; 5 | private int gear = 1; 6 | private int candence = 0; 7 | 8 | public void changeCandence(int newVaue) 9 | { 10 | candence = newVaue; 11 | } 12 | 13 | public void changeGear(int newValue) 14 | { 15 | gear = newValue; 16 | } 17 | 18 | public void speedUp(int increment) 19 | { 20 | speed = speed + increment; 21 | } 22 | 23 | public void applyBrakes(int decrement) 24 | { 25 | speed = speed - decrement; 26 | } 27 | 28 | public void printStates() 29 | { 30 | System.out.println("candence: " + candence + " speed: "+ speed + " gear: " + gear); 31 | } 32 | 33 | // public static class Main { 34 | // 35 | // public static void main(String[] args) { 36 | // 37 | // Bicycle bike1 = new Bicycle(); 38 | // bike1.printStates(); 39 | // } 40 | // } 41 | } 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /OOPbasic/src/OOPs/EnumExamp.java: -------------------------------------------------------------------------------- 1 | package OOPs; 2 | 3 | public class EnumExamp { 4 | public enum Day{ 5 | SATUERDAY, SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY 6 | } 7 | 8 | public static void main(String[] args) 9 | { 10 | // Day today = Day.MONDAY; 11 | // System.out.println(today); 12 | Day[] days = Day.values(); 13 | for(Day d:days) 14 | { 15 | System.out.println(d); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OOPbasic/src/OOPs/Main.java: -------------------------------------------------------------------------------- 1 | package OOPs; 2 | 3 | public class Main { 4 | public static void main(String[] args) 5 | { 6 | // Bicycle bike1 = new Bicycle(); 7 | // bike1.changeCandence(50); 8 | // bike1.speedUp(10); 9 | // bike1.changeGear(2); 10 | // bike1.printStates(); 11 | 12 | 13 | 14 | // int result = obj.addition(4, 5); 15 | // double resultf = obj.addition(5.5f, 5.9f); // Use 'f' suffix for float literals 16 | // System.out.println(resultf); 17 | 18 | StudentMarks ruhul = new StudentMarks("ruhul", new double[]{98.5, 65.22, 55.5}); 19 | double totalMarks = ruhul.totalMarks(); 20 | double average = ruhul.avereage(); 21 | System.out.println("total mark " + totalMarks + " and average " + average); 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /OOPbasic/src/OOPs/MthodOverload.java: -------------------------------------------------------------------------------- 1 | package OOPs; 2 | 3 | public class MthodOverload { 4 | public int addition(int a, int b) 5 | { 6 | int result = a + b; 7 | return result; 8 | } 9 | 10 | public double addition(double a, double b) 11 | { 12 | double result = a + b; 13 | return result; 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OOPbasic/src/OOPs/StudentMarks.java: -------------------------------------------------------------------------------- 1 | package OOPs; 2 | 3 | public class StudentMarks { 4 | private final String name; 5 | private final double[] marks; 6 | 7 | public StudentMarks(String name, double[] marks) { 8 | this.name = name; 9 | this.marks = marks; 10 | } 11 | 12 | public double avereage(){ 13 | return totalMarks() / marks.length; 14 | } 15 | 16 | public double totalMarks() 17 | { 18 | double totalMarks = 0.0; 19 | for(double mark: marks) 20 | { 21 | totalMarks += mark; 22 | } 23 | return totalMarks; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /OOPbasic/src/Polymorphism/Coffee.java: -------------------------------------------------------------------------------- 1 | package Polymorphism; 2 | 3 | import java.lang.Override; 4 | public class Coffee extends Liquid { 5 | 6 | @Override 7 | public void swirl(boolean clockwise) { 8 | System.out.println("Swirling coffee"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OOPbasic/src/Polymorphism/Cup.java: -------------------------------------------------------------------------------- 1 | package Polymorphism; 2 | 3 | import java.util.ArrayList; 4 | public class Cup { 5 | public ArrayList liquids = new ArrayList<>(); 6 | public void addLiquid(Liquid liquid){ 7 | liquids.add(liquid); 8 | } 9 | public void mix(){ 10 | for (Liquid liquid: liquids){ 11 | liquid.swirl(true); 12 | } 13 | } 14 | 15 | public void juice(){ 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OOPbasic/src/Polymorphism/Liquid.java: -------------------------------------------------------------------------------- 1 | package Polymorphism; 2 | 3 | public class Liquid { 4 | public void swirl(boolean clockwise){ 5 | System.out.println("swirling liquid"); 6 | } 7 | 8 | } 9 | -------------------------------------------------------------------------------- /OOPbasic/src/Polymorphism/Main.java: -------------------------------------------------------------------------------- 1 | package Polymorphism; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | 6 | // Liquid myFavouriteBeverage = new Liquid(); 7 | // myFavouriteBeverage.swirl(true); 8 | 9 | Liquid genericLiquid = new Liquid(); 10 | Liquid milk = new Milk(); 11 | Liquid coffee = new Coffee(); 12 | 13 | Cup cup = new Cup(); 14 | cup.addLiquid(genericLiquid); 15 | cup.addLiquid(milk); 16 | cup.addLiquid(coffee); 17 | cup.mix(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OOPbasic/src/Polymorphism/Milk.java: -------------------------------------------------------------------------------- 1 | package Polymorphism; 2 | import java.lang.Override; 3 | 4 | public class Milk extends Liquid{ 5 | @Override 6 | public void swirl(boolean clockwise){ 7 | System.out.println("Swirling milk"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /OOPbasic/src/Polymorphism2/Circle.java: -------------------------------------------------------------------------------- 1 | package Polymorphism2; 2 | 3 | public class Circle extends Shape{ 4 | public Circle(){ 5 | super("Circle"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /OOPbasic/src/Polymorphism2/DrawingDemo.java: -------------------------------------------------------------------------------- 1 | package Polymorphism2; 2 | 3 | public class DrawingDemo { 4 | public static void main(String[] args) { 5 | DrawingPad pad = new DrawingPad(); 6 | Circle circle = new Circle(); 7 | Square square = new Square(); 8 | 9 | pad.draw(circle); 10 | pad.draw(square); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OOPbasic/src/Polymorphism2/DrawingPad.java: -------------------------------------------------------------------------------- 1 | package Polymorphism2; 2 | 3 | public class DrawingPad { 4 | 5 | public void draw(Shape shape) 6 | { 7 | System.out.println("Drawing " + shape.getName()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /OOPbasic/src/Polymorphism2/Shape.java: -------------------------------------------------------------------------------- 1 | package Polymorphism2; 2 | 3 | public class Shape { 4 | private final String name; 5 | 6 | public Shape(String name){ 7 | this.name = name; 8 | } 9 | 10 | public String getName(){ 11 | return name; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /OOPbasic/src/Polymorphism2/Square.java: -------------------------------------------------------------------------------- 1 | package Polymorphism2; 2 | 3 | public class Square extends Shape{ 4 | public Square(){ 5 | super("Square"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /OOPbasic/src/PostAbstract/Client.java: -------------------------------------------------------------------------------- 1 | package PostAbstract; 2 | 3 | public class Client { 4 | private final String name; 5 | private final int hoursWorked; 6 | 7 | public Client(String name, int hoursWorked){ 8 | this.name = name; 9 | this.hoursWorked = hoursWorked; 10 | } 11 | 12 | public String getName(){ 13 | 14 | return name; 15 | } 16 | 17 | public int getHoursWorked(){ 18 | 19 | return hoursWorked; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OOPbasic/src/PostAbstract/FixedPayCalculator.java: -------------------------------------------------------------------------------- 1 | package PostAbstract; 2 | 3 | public class FixedPayCalculator extends PayCalculator{ 4 | private double fixedPay; 5 | 6 | public FixedPayCalculator(double fixedPay){ 7 | this.fixedPay = fixedPay; 8 | } 9 | 10 | @Override 11 | public double getPay(Client client){ 12 | return fixedPay; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OOPbasic/src/PostAbstract/HourlyPayCalculator.java: -------------------------------------------------------------------------------- 1 | package PostAbstract; 2 | 3 | public class HourlyPayCalculator extends PayCalculator{ 4 | private final double hourlyRate; 5 | public HourlyPayCalculator(double hourlyRate) 6 | { 7 | this.hourlyRate = hourlyRate; 8 | } 9 | @Override 10 | public double getPay(Client client){ 11 | return hourlyRate * client.getHoursWorked(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /OOPbasic/src/PostAbstract/HrManager.java: -------------------------------------------------------------------------------- 1 | package PostAbstract; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class HrManager { 6 | private final ArrayList clients = new ArrayList<>(); 7 | private PayCalculator payCalculator; 8 | 9 | public HrManager(PayCalculator payCalculator){ 10 | this.payCalculator = payCalculator; 11 | } 12 | public void addClient(Client client){ 13 | 14 | clients.add(client); 15 | } 16 | public double getTotalPay(){ 17 | double total = 0.0; 18 | for (Client client: clients){ 19 | total += payCalculator.getPay(client); 20 | } 21 | return total; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /OOPbasic/src/PostAbstract/Main.java: -------------------------------------------------------------------------------- 1 | package PostAbstract; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | PayCalculator calculator = new FixedPayCalculator(75); 6 | HrManager hrManager = new HrManager(calculator); 7 | 8 | Client client0 = new Client("karim", 45); 9 | hrManager.addClient(client0); 10 | 11 | Client client1 = new Client("Latip", 41); 12 | hrManager.addClient(client1); 13 | 14 | double fixedTotalPay = hrManager.getTotalPay(); 15 | System.out.println("fixedTotalPay = "+ fixedTotalPay); 16 | 17 | // PayCalculator calculator = new HourlyPayCalculator(75); 18 | // HrManager hrManager = new HrManager(calculator); 19 | // 20 | // Client client0 = new Client("karim", 45); 21 | // hrManager.addClient(client0); 22 | // 23 | // Client client1 = new Client("Latip", 41); 24 | // hrManager.addClient(client1); 25 | // 26 | // double hourlyTotalPay = hrManager.getTotalPay(); 27 | // System.out.println("hourlyTotalPay = "+ hourlyTotalPay); 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /OOPbasic/src/PostAbstract/PayCalculator.java: -------------------------------------------------------------------------------- 1 | package PostAbstract; 2 | 3 | public abstract class PayCalculator { 4 | public abstract double getPay(Client client); 5 | } 6 | -------------------------------------------------------------------------------- /OOPbasic/src/PreAbstract/Client.java: -------------------------------------------------------------------------------- 1 | package PreAbstract; 2 | 3 | public class Client { 4 | private final String name; 5 | private final int hoursWorked; 6 | 7 | public Client(String name, int hoursWorked){ 8 | this.name = name; 9 | this.hoursWorked = hoursWorked; 10 | } 11 | 12 | public String getName(){ 13 | return name; 14 | } 15 | 16 | public int getHoursWorked(){ 17 | return hoursWorked; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OOPbasic/src/PreAbstract/HrManager.java: -------------------------------------------------------------------------------- 1 | package PreAbstract; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class HrManager { 6 | private ArrayList clients = new ArrayList<>(); 7 | private PayCalculator payCalculator = new PayCalculator(); 8 | 9 | public void addClient(Client client){ 10 | clients.add(client); 11 | } 12 | public double getTotalPay(String method){ 13 | double total = 0.0; 14 | for (Client client: clients){ 15 | total += payCalculator.getPay(client, method); 16 | } 17 | return total; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OOPbasic/src/PreAbstract/Main.java: -------------------------------------------------------------------------------- 1 | package PreAbstract; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | HrManager hrManager = new HrManager(); 6 | 7 | Client client0 = new Client("rahim", 50); 8 | hrManager.addClient(client0); 9 | 10 | Client client1 = new Client("Karim", 40); 11 | hrManager.addClient(client1); 12 | 13 | double totalFixedPay = hrManager.getTotalPay("FIXED"); 14 | System.out.println("Total FIXED pay = "+ totalFixedPay); 15 | 16 | double hourlyTotalPay = hrManager.getTotalPay("HOURLY"); 17 | System.out.println("Total HOURLY pay = "+ hourlyTotalPay); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OOPbasic/src/PreAbstract/PayCalculator.java: -------------------------------------------------------------------------------- 1 | package PreAbstract; 2 | 3 | public class PayCalculator { 4 | private static final double HOURLY_RATE = 70; 5 | private static final double FIXED_PAY = 550; 6 | 7 | public double getPay(Client client, String method){ 8 | return switch (method){ 9 | case "HOURLY" -> client.getHoursWorked() * HOURLY_RATE; 10 | case "FIXED" -> FIXED_PAY; 11 | default -> throw new IllegalArgumentException( 12 | "Unknown method: " + method 13 | ); 14 | }; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OOPbasic/src/Set/HashSetExp.java: -------------------------------------------------------------------------------- 1 | // hashSet make a ascending order 2 | package Set; 3 | 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | 7 | public class HashSetExp { 8 | public static void main(String[] args) { 9 | Set cities = new HashSet<>(); 10 | 11 | cities.add("Feni"); 12 | cities.add("CUmmilla"); 13 | cities.add("Feni"); 14 | cities.add("Lalmatia"); 15 | cities.add("abd"); 16 | cities.add("abc"); 17 | 18 | for (String city:cities){ 19 | System.out.println(city); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OOPbasic/src/Set/LinkedHashExp.java: -------------------------------------------------------------------------------- 1 | package Set; 2 | 3 | import java.util.LinkedHashSet; 4 | import java.util.Set; 5 | 6 | public class LinkedHashExp { 7 | public static void main(String[] args) { 8 | Set cities = new LinkedHashSet<>(); 9 | cities.add("Feni"); 10 | cities.add("CUmmilla"); 11 | cities.add("Feni"); 12 | cities.add("Lalmatia"); 13 | cities.add("abd"); 14 | cities.add("abc"); 15 | 16 | System.out.println(cities); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OOPbasic/src/Set/TreeSetExp.java: -------------------------------------------------------------------------------- 1 | package Set; 2 | 3 | import java.util.Set; 4 | import java.util.TreeSet; 5 | 6 | public class TreeSetExp { 7 | public static void main(String[] args) { 8 | Set numbers = new TreeSet<>(); 9 | numbers.add(5); 10 | numbers.add(8); 11 | numbers.add(1); 12 | System.out.println(numbers); 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /OOPbasic/src/interface1/BkashPayment.java: -------------------------------------------------------------------------------- 1 | package interface1; 2 | 3 | public class BkashPayment implements Payment{ 4 | private final double amount; 5 | 6 | public BkashPayment(double amount){ 7 | this.amount = amount; 8 | } 9 | 10 | @Override 11 | public double getAmount(){ 12 | System.out.println("Taking bkash Payment"); 13 | return amount; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OOPbasic/src/interface1/CashPayment.java: -------------------------------------------------------------------------------- 1 | package interface1; 2 | 3 | public class CashPayment implements Payment { 4 | private final double amount; 5 | 6 | public CashPayment(double amount) { 7 | 8 | this.amount = amount; 9 | } 10 | 11 | @Override 12 | public double getAmount() { 13 | System.out.println("Taking Cash Amount"); 14 | return amount; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OOPbasic/src/interface1/Payment.java: -------------------------------------------------------------------------------- 1 | package interface1; 2 | 3 | public interface Payment { 4 | double getAmount(); 5 | } 6 | -------------------------------------------------------------------------------- /OOPbasic/src/interface1/PaymentDemo.java: -------------------------------------------------------------------------------- 1 | package interface1; 2 | 3 | public class PaymentDemo { 4 | public static void main(String[] args) { 5 | PaymentEngine paymentEngine = new PaymentEngine(); 6 | 7 | BkashPayment bkashPayment = new BkashPayment(100); 8 | paymentEngine.accept(bkashPayment); 9 | 10 | CashPayment cashPayment = new CashPayment(50); 11 | paymentEngine.accept(cashPayment); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OOPbasic/src/interface1/PaymentEngine.java: -------------------------------------------------------------------------------- 1 | package interface1; 2 | 3 | public class PaymentEngine { 4 | public void accept(Payment payment){ 5 | 6 | System.out.println("Accepting Payment: "+ payment.getAmount()); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /OOPbasic/src/interface2samePostAbstract/Client.java: -------------------------------------------------------------------------------- 1 | package interface2samePostAbstract; 2 | 3 | public class Client { 4 | private final String name; 5 | private final int hoursWorked; 6 | 7 | public Client(String name, int hoursWorked){ 8 | this.name = name; 9 | this.hoursWorked = hoursWorked; 10 | } 11 | 12 | public String getName(){ 13 | 14 | return name; 15 | } 16 | 17 | public int getHoursWorked(){ 18 | 19 | return hoursWorked; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /OOPbasic/src/interface2samePostAbstract/FixedPayCalculator.java: -------------------------------------------------------------------------------- 1 | package interface2samePostAbstract; 2 | 3 | public class FixedPayCalculator implements PayCalculator { 4 | private double fixedPay; 5 | 6 | public FixedPayCalculator(double fixedPay) { 7 | 8 | this.fixedPay = fixedPay; 9 | } 10 | 11 | @Override 12 | public double getPay(Client client) { 13 | return fixedPay; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OOPbasic/src/interface2samePostAbstract/HourlyPayCalculator.java: -------------------------------------------------------------------------------- 1 | package interface2samePostAbstract; 2 | 3 | public class HourlyPayCalculator implements PayCalculator { 4 | private final double hourlyRate; 5 | public HourlyPayCalculator(double hourlyRate) 6 | { 7 | this.hourlyRate = hourlyRate; 8 | } 9 | @Override 10 | public double getPay(Client client){ 11 | return hourlyRate * client.getHoursWorked(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /OOPbasic/src/interface2samePostAbstract/HrManager.java: -------------------------------------------------------------------------------- 1 | package interface2samePostAbstract; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class HrManager { 6 | private final ArrayList clients = new ArrayList<>(); 7 | private PayCalculator payCalculator; 8 | 9 | public HrManager(PayCalculator payCalculator){ 10 | this.payCalculator = payCalculator; 11 | } 12 | public void addClient(Client client){ 13 | 14 | clients.add(client); 15 | } 16 | public double getTotalPay(){ 17 | double total = 0.0; 18 | for (Client client: clients){ 19 | total += payCalculator.getPay(client); 20 | } 21 | return total; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /OOPbasic/src/interface2samePostAbstract/Main.java: -------------------------------------------------------------------------------- 1 | package interface2samePostAbstract; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | PayCalculator calculator = new FixedPayCalculator(75); 6 | HrManager hrManager = new HrManager(calculator); 7 | 8 | Client client0 = new Client("karim", 45); 9 | hrManager.addClient(client0); 10 | 11 | Client client1 = new Client("Latip", 41); 12 | hrManager.addClient(client1); 13 | 14 | double fixedTotalPay = hrManager.getTotalPay(); 15 | System.out.println("fixedTotalPay = "+ fixedTotalPay); 16 | 17 | // PayCalculator calculator = new HourlyPayCalculator(75); 18 | // HrManager hrManager = new HrManager(calculator); 19 | // 20 | // Client client0 = new Client("karim", 45); 21 | // hrManager.addClient(client0); 22 | // 23 | // Client client1 = new Client("Latip", 41); 24 | // hrManager.addClient(client1); 25 | // 26 | // double hourlyTotalPay = hrManager.getTotalPay(); 27 | // System.out.println("hourlyTotalPay = "+ hourlyTotalPay); 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /OOPbasic/src/interface2samePostAbstract/PayCalculator.java: -------------------------------------------------------------------------------- 1 | package interface2samePostAbstract; 2 | 3 | public interface PayCalculator { 4 | double getPay(Client client); 5 | } 6 | -------------------------------------------------------------------------------- /ProblemSolving/.gitignore: -------------------------------------------------------------------------------- 1 | ### IntelliJ IDEA ### 2 | out/ 3 | !**/src/main/**/out/ 4 | !**/src/test/**/out/ 5 | 6 | ### Eclipse ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | bin/ 15 | !**/src/main/**/bin/ 16 | !**/src/test/**/bin/ 17 | 18 | ### NetBeans ### 19 | /nbproject/private/ 20 | /nbbuild/ 21 | /dist/ 22 | /nbdist/ 23 | /.nb-gradle/ 24 | 25 | ### VS Code ### 26 | .vscode/ 27 | 28 | ### Mac OS ### 29 | .DS_Store -------------------------------------------------------------------------------- /ProblemSolving/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /ProblemSolving/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ProblemSolving/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ProblemSolving/.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /ProblemSolving/ProblemSolving.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ProblemSolving/src/ProblemSolving/Main.java: -------------------------------------------------------------------------------- 1 | package ProblemSolving; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | 6 | System.out.println("Hello world!"); 7 | } 8 | } -------------------------------------------------------------------------------- /ProblemSolving/src/ProblemSolving/StringToCharCount.java: -------------------------------------------------------------------------------- 1 | package ProblemSolving; 2 | 3 | import java.util.Scanner; 4 | 5 | public class StringToCharCount { 6 | public static void main(String[] args) 7 | { 8 | Scanner input = new Scanner(System.in); 9 | String str = input.nextLine(); 10 | str = str.toLowerCase(); 11 | char[] letters = str.toCharArray(); 12 | int[] counts = new int[26]; 13 | for (int i = 0; i < letters.length; i++) 14 | { 15 | if(Character.isLetter(letters[i])){ 16 | int indx = letters[i] - 'a'; 17 | counts[indx]++; 18 | } 19 | } 20 | for(int i = 0; i < counts.length; i++) 21 | { 22 | if(counts[i] > 0) 23 | { 24 | char ch = (char) (i + 'a'); 25 | System.out.println(ch + " = " + counts[i]); 26 | } 27 | 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Testing/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /Testing/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /Testing/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Testing/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Testing/Drivers/chromedriver.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdruhulkuddus/java-learning/1751b485cf8ccf321210fc24297cce0413d08106/Testing/Drivers/chromedriver.exe -------------------------------------------------------------------------------- /Testing/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | Testing 8 | Testing 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 17 13 | 17 14 | UTF-8 15 | 16 | 17 | 18 | 19 | org.seleniumhq.selenium 20 | selenium-java 21 | 4.18.1 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Testing/src/main/java/Testing/Main.java: -------------------------------------------------------------------------------- 1 | package Testing; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | System.out.println("Hello world!"); 6 | } 7 | } -------------------------------------------------------------------------------- /Testing/src/test/java/Test/Demo1.java: -------------------------------------------------------------------------------- 1 | package Test; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.openqa.selenium.chrome.ChromeDriver; 5 | 6 | public class Demo1 { 7 | public static void main(String[] args) 8 | { 9 | System.setProperty("webdriver.chrome.driver", "F:\\JavaLearning\\Testing\\Drivers\\chromedriver.exe"); 10 | 11 | WebDriver driver = new ChromeDriver(); 12 | driver.get("https://opensource-demo.orangehrmlive.com/"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /helloworld/.gitignore: -------------------------------------------------------------------------------- 1 | ### IntelliJ IDEA ### 2 | out/ 3 | !**/src/main/**/out/ 4 | !**/src/test/**/out/ 5 | 6 | ### Eclipse ### 7 | .apt_generated 8 | .classpath 9 | .factorypath 10 | .project 11 | .settings 12 | .springBeans 13 | .sts4-cache 14 | bin/ 15 | !**/src/main/**/bin/ 16 | !**/src/test/**/bin/ 17 | 18 | ### NetBeans ### 19 | /nbproject/private/ 20 | /nbbuild/ 21 | /dist/ 22 | /nbdist/ 23 | /.nb-gradle/ 24 | 25 | ### VS Code ### 26 | .vscode/ 27 | 28 | ### Mac OS ### 29 | .DS_Store -------------------------------------------------------------------------------- /helloworld/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /helloworld/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /helloworld/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /helloworld/.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /helloworld/JavaBasics.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/Array2.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Array2 { 6 | public static void main(String[] args) 7 | { 8 | Scanner input = new Scanner(System.in); 9 | System.out.println("Size of Array : "); 10 | int sizeofArray = input.nextInt(); 11 | System.out.println("Input : " + sizeofArray + " values "); 12 | int[] numbers = new int[sizeofArray]; 13 | for (int i = 0; i < sizeofArray; i++) 14 | { 15 | numbers[i] = input.nextInt(); 16 | } 17 | System.out.println("Output Array : "); 18 | for (int i = 0; i < sizeofArray; i++) 19 | { 20 | System.out.println(numbers[i]); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/ArrayPrint.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | import java.util.ArrayList; 3 | import java.util.Arrays; 4 | 5 | public class ArrayPrint { 6 | public static void main(String [] args){ 7 | int [] arr = {50,50, 48, 32, 15, 17, 52}; 8 | System.out.println(Arrays.toString(arr)); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/ArrayToStr.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.Arrays; 4 | import java.util.Scanner; 5 | 6 | public class ArrayToStr { 7 | public static void main(String [] args) 8 | { 9 | Scanner input = new Scanner(System.in); 10 | System.out.println("Size of Array : "); 11 | int sizeofArray = input.nextInt(); 12 | System.out.println("Input : " + sizeofArray + " values "); 13 | int[] numbers = new int[sizeofArray]; 14 | for (int i = 0; i < sizeofArray; i++) 15 | { 16 | numbers[i] = input.nextInt(); 17 | } 18 | System.out.println("Output Array as String : "+ Arrays.toString(numbers)); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/Arre.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class Arre { 4 | public static void main(String [] args) 5 | { 6 | int[] myArray = {-1, 2, 5 , 6, 8}; 7 | System.out.println("index \t value"); 8 | for(int i = 0; i < myArray.length; i++) 9 | { 10 | System.out.println(i +"\t"+myArray[i]); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/AsciiTable.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class AsciiTable { 4 | public static void main(String[] args) 5 | { 6 | char a = 'a'; 7 | int asciiValueOfA = (int) a; 8 | System.out.println(asciiValueOfA); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/DecimalToHexBiOctal.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class DecimalToHexBiOctal { 4 | public static void main(String[] args) 5 | { 6 | int d_number = 1_000_000; // 1 million 7 | String binary = Integer.toBinaryString(d_number); 8 | String hex = Integer.toHexString(d_number); 9 | String octal = Integer.toOctalString(d_number); 10 | 11 | System.out.println("Binary: " + binary); 12 | System.out.println("Hex: " + hex); 13 | System.out.println("Octal: " + octal); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/Dr.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Dr { 6 | public static void main(String [] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | int number = scanner.nextInt(); 9 | StringBuilder result = new StringBuilder("I hate"); 10 | for(int i = 2; i <= number; i++) 11 | { 12 | if(i%2 == 0){ 13 | result.append(" that I love"); 14 | }else{ 15 | result.append(" that I hate"); 16 | } 17 | } 18 | result.append(" it"); 19 | System.out.println(result); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/FnBracketBalanceChecker.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.Scanner; 4 | import java.util.Stack; 5 | 6 | public class FnBracketBalanceChecker { 7 | public boolean isBalanced(String input) { 8 | if (input.length() % 2 == 1) { 9 | return false; 10 | } 11 | Stack stk = new Stack<>(); 12 | for (char c : input.toCharArray()) { 13 | if (c == '(') { 14 | stk.push(c); 15 | } else if (c == ')' && (stk.isEmpty() || stk.pop() != '(')) { 16 | return false; 17 | } 18 | } 19 | return stk.isEmpty(); 20 | } 21 | 22 | public static void main(String[] args) { 23 | Scanner input = new Scanner(System.in); 24 | String str = input.nextLine(); 25 | 26 | FnBracketBalanceChecker checker = new FnBracketBalanceChecker(); 27 | if (checker.isBalanced(str)) { 28 | System.out.println("Balanced!"); 29 | } else { 30 | System.out.println("Not Balanced"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/IntFloating.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class IntFloating { 4 | public static void main(String[] args) 5 | { 6 | System.out.println(1/3); // int 7 | System.out.println(1.0/3); // float 8 | System.out.println(1/3.0); 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/JavaToASCII.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class JavaToASCII { 4 | public static void main (String[] args) 5 | { 6 | char a = 'a'; 7 | int AsciiValue = a; 8 | System.out.println("asci value of a = " + AsciiValue); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/Main.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | 6 | System.out.println("Hello world!"); 7 | System.out.println("Hello world!"); 8 | System.out.println("Hello world!"); 9 | System.out.println("Hello world!"); 10 | } 11 | } -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/Mathmatian.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Mathmatian { 6 | public static void main(String [] args) 7 | { 8 | Scanner input = new Scanner(System.in); 9 | String firstString = input.nextLine(); 10 | String secondString = input.nextLine(); 11 | String result = ""; 12 | for(int i = 0; i < firstString.length(); i++) 13 | { 14 | if(firstString.charAt(i) != secondString.charAt(i)) 15 | { 16 | result += "1"; 17 | }else { 18 | result += "0"; 19 | } 20 | } 21 | System.out.println(result); 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/MaxValue.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class MaxValue { 4 | public static void main(String [] args) 5 | { 6 | byte byteMax = Byte.MAX_VALUE; 7 | System.out.println(byteMax); 8 | byte byteMin = Byte.MIN_VALUE; 9 | System.out.println(byteMin); 10 | 11 | short maxShort = Short.MAX_VALUE; 12 | System.out.println(maxShort); 13 | short minShort = Short.MIN_VALUE; 14 | System.out.println(minShort); 15 | 16 | int maxInt = Integer.MAX_VALUE; 17 | System.out.println(maxInt); 18 | int minInt = Integer.MIN_VALUE; 19 | System.out.println(minInt); 20 | 21 | long longMax = Long.MAX_VALUE; 22 | System.out.println(longMax); 23 | long longMin = Long.MIN_VALUE; 24 | System.out.println(longMin); 25 | 26 | float maxFloat = Float.MAX_VALUE; 27 | System.out.println(maxFloat); 28 | float minFloat = Float.MIN_VALUE; 29 | System.out.println(minFloat); 30 | 31 | double maxDouble = Double.MAX_VALUE; 32 | System.out.println(maxDouble); 33 | double minDouble = Double.MIN_VALUE; 34 | System.out.println(minDouble); 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/Numeric.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class Numeric { 4 | 5 | public static void main(String[] args) 6 | { 7 | int x1 = 2_105_50; 8 | System.out.println(x1); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/StringJoinerExp.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.StringJoiner; 4 | 5 | public class StringJoinerExp { 6 | public static void main(String [] args) 7 | { 8 | String[] cities = {"Dhaka", "Comilla", "Chittagong", "Rajshahi", "Rangpur"}; 9 | StringJoiner joiner = new StringJoiner(", "); 10 | for(String city: cities) 11 | { 12 | joiner.add(city); 13 | } 14 | System.out.println("Cities of Bangladesh: "+ joiner); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/TextBlock.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class TextBlock { 4 | public static void main(String [] args) 5 | { 6 | String table = """ 7 | +---------------------+-----------------------------+ 8 | | Name | Ruhul Kuddus | 9 | + + 10 | | Department | CSE | 11 | +---------------------------------------------------+ 12 | """; 13 | 14 | System.out.println(table); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/TwoDimentionalArr.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.Scanner; 4 | 5 | public class TwoDimentionalArr { 6 | public static void main(String [] args) { 7 | int[][] array1 = { 8 | {1, 2, 3, 5}, 9 | {4, 5, 6}, 10 | {7, 8, 9} 11 | }; 12 | System.out.println(array1.length + " \t " + array1[0].length); 13 | for (int i = 0; i < array1.length; i++) 14 | { 15 | for (int j = 0; j < array1[i].length; j++) 16 | { 17 | System.out.print(array1[i][j] + " "); 18 | } 19 | System.out.print("\n"); 20 | } 21 | System.out.println("Now input your Matrix \n"); 22 | Scanner input = new Scanner(System.in); 23 | System.out.println("Enter row and colum size : "); 24 | int row = input.nextInt(); 25 | int col = input.nextInt(); 26 | int[][] matrix = new int[row][col]; 27 | 28 | System.out.println("Enter " + row + " * " + col + " Matrix: "); 29 | for(int i = 0; i < row; i++) 30 | { 31 | for(int j = 0; j < col; j++) 32 | { 33 | matrix[i][j] = input.nextInt(); 34 | } 35 | } 36 | 37 | for(int i = 0; i < row; i++) 38 | { 39 | for(int j = 0; j < col; j++) 40 | { 41 | System.out.print(matrix[i][j] + " "); 42 | } 43 | System.out.println(); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/eof.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | import java.util.Scanner; 3 | public class eof { 4 | 5 | 6 | 7 | public static void main(String[] args) { 8 | Scanner sc = new Scanner(System.in); 9 | for(int i = 1; sc.hasNext()== true; i++){ 10 | System.out.println(i + " " + sc.nextLine()); 11 | } 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/forEachLoop.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class forEachLoop { 4 | public static void main(String[] args) 5 | { 6 | int[] arr = {-58, 88, 699, 88, 9}; 7 | for (int number: arr) 8 | { 9 | System.out.println(number); 10 | } 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/horseshoe.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.HashSet; 4 | import java.util.Scanner; 5 | import java.util.Set; 6 | 7 | public class horseshoe { 8 | public static void main(String [] args) 9 | { 10 | Scanner scanner = new Scanner(System.in); 11 | Set integerSet = new HashSet<>(); 12 | 13 | for(int i = 0; i < 4; i++) 14 | { 15 | int number = scanner.nextInt(); 16 | integerSet.add(number); 17 | } 18 | int result = 4-integerSet.size(); 19 | System.out.println(result); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/input.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.Scanner; 4 | 5 | public class input { 6 | public static void main (String[] args) 7 | { 8 | Scanner inpt = new Scanner(System.in); 9 | System.out.println("Enter a Number: "); 10 | int number = inpt.nextInt(); 11 | System.out.println("number = " + number); 12 | 13 | System.out.println("Enter a Name: "); 14 | String text = inpt.next(); 15 | System.out.println("Name: " + text); 16 | 17 | System.out.println("Enter a GPA: "); 18 | double gpa = inpt.nextDouble(); 19 | System.out.println("Gpa: " + gpa); 20 | 21 | 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/loop.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.Scanner; 4 | 5 | public class loop { 6 | public static void main (String [] args) 7 | { 8 | Scanner input = new Scanner(System.in); 9 | int multiplication = input.nextInt(); 10 | 11 | for(int i = 1; i <= 10; i++) 12 | { 13 | System.out.println(multiplication + " * " + i + " = " + multiplication * i); 14 | } 15 | int multiplication2 = input.nextInt(); 16 | int j = 0; 17 | while (j != 11) 18 | { 19 | System.out.println(multiplication2 + " * " + j + " = " + multiplication2 * j); 20 | j++; 21 | } 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/overflowUnderflow.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class overflowUnderflow { 4 | public static void main(String [] args) 5 | { 6 | // overflow 7 | int val = 2147483647; 8 | System.out.println(val); 9 | 10 | val += 1 ; 11 | System.out.println(val); 12 | 13 | val += 1 ; 14 | System.out.println(val); 15 | 16 | // under flow 17 | val -= 2; 18 | System.out.println(val); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/print.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class print { 4 | public static void main(String[] args) 5 | { 6 | System.out.println("2+3 = "+ (2+3)); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/twoNumberCompare.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | import java.util.Scanner; 4 | 5 | public class twoNumberCompare { 6 | public static void main(String [] args) 7 | { 8 | Scanner input = new Scanner(System.in); 9 | int a = input.nextInt(); 10 | int b = input.nextInt(); 11 | 12 | boolean isEqual = a == b; 13 | boolean notEqual = a != b; 14 | boolean isGaterA = a > b; 15 | boolean isGaterB = a < b; 16 | 17 | System.out.println("Equal = " + isEqual); 18 | System.out.println("Not equal = " + notEqual); 19 | System.out.println("A is Grater than B = " + isGaterA); 20 | System.out.println("B is Grater than A = " + isGaterB); 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /helloworld/src/JavaBasics/typeCasting.java: -------------------------------------------------------------------------------- 1 | package JavaBasics; 2 | 3 | public class typeCasting { 4 | public static void main(String [] args) 5 | { 6 | double aDoubel = 5454.6554; 7 | System.out.println(aDoubel); 8 | long aLong = (long)(aDoubel); 9 | System.out.println(aLong); 10 | 11 | } 12 | } 13 | --------------------------------------------------------------------------------