This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singleton { | |
// This is an object of the same class, but give more attention towards | |
// private :- This object cannot be accessed from outside, you have use getter (getInstance) method | |
// static :- This object is static as getInstance have to be static (Why?? You'll know) and | |
// only static variables can be accessed in static methods | |
private static Singleton INSTANCE = null; | |
// Ofcourse a class is of no use if it does not have any data (So this is the data for which every thread will fight) | |
private String criticalData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" | |
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:sec="http://www.springframework.org/schema/security" | |
xsi:schemaLocation=" | |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd | |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd | |
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd | |
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd" | |
default-autowire="byName"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BadConstructor{ | |
public String param1; | |
public int param2; | |
public char[] param3; | |
public AnotherClass param4; | |
public List param5; | |
public Set param6; | |
public BadConstructor(String param1, int param2, char[] param3, AnotherClass param4, List<String> param5, HashSet<String> param6){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Shape{ | |
//It could be a circle or rectangle or square | |
private String type; | |
//To calculate area of rectangle | |
public Double area(Long length, Long breadth){ | |
return (Double) length * breadth; | |
} | |
//To calculate area of a circle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static String valueOf(boolean b) | |
static String valueOf(char c) | |
static String valueOf(char[] data) | |
static String valueOf(char[] data, int offset, int count) | |
static String valueOf(double d) | |
static String valueOf(float f) | |
static String valueOf(int i) | |
static String valueOf(long l) | |
static String valueOf(Object obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Shape{ | |
public abstract Double area(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Circle extends Shape { | |
private Double radius = 5.0; | |
// See this annotation @Override, it is telling that this method is from parent | |
// class Shape and is overridden here | |
@Override | |
public Double area(){ | |
return 3.14 * radius * radius; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Rectangle extends Shape { | |
private Double length = 5.0; | |
private Double breadth= 10.0; | |
// See this annotation @Override, it is telling that this method is from parent | |
// class Shape and is overridden here | |
@Override | |
public Double area(){ | |
return length * breadth; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AreaFinder{ | |
public static void main(String[] args){ | |
//This will create an object of circle class | |
Shape circle = new Circle(); | |
//This will create an object of Rectangle class | |
Shape rectangle = new Rectangle(); | |
// Drumbeats …… | |
//This should print 78.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Eatable { | |
default void taste(){ | |
System.out.println("YeYe this tastes great"); | |
} | |
} |
OlderNewer