Java Spring Detailed Guide
Java Spring Detailed Guide
Example:
List<String> list = new ArrayList<>();
list.add("Apple"); list.add("Banana");
2. Hierarchy of Collection Framework
Collection (Interface)
List (ArrayList, LinkedList, Vector, Stack)
Set (HashSet, LinkedHashSet, TreeSet)
Queue (PriorityQueue, LinkedList)
Map (Interface) is a separate hierarchy.
Example:
Map<Integer, String> map = new HashMap<>();
map.put(1, "One");
3. Iterator Interface
Example:
Iterator<String> it = list.iterator();
while(it.hasNext()) System.out.println(it.next());
4. List Interface & Implementations
Example:
List<String> items = new ArrayList<>();
items.add("Pen"); items.add("Book");
5. Queue Interface
Example:
Queue<String> q = new LinkedList<>();
q.add("A"); q.add("B");
System.out.println(q.poll()); // Outputs "A"
6. Set Interface & Implementations
Java Collections, Spring Framework & Spring Boot - Detailed Guide
Example:
Set<String> s = new HashSet<>();
s.add("Dog"); s.add("Cat");
7. Map Interface & Classes
Example:
Map<String, Integer> scores = new HashMap<>();
scores.put("Math", 95);
8. Comparable and Comparator Interfaces
Example:
Properties p = new Properties();
p.setProperty("url", "localhost");
10. Spring Core Basics and Dependency Injection
@Component
class Car {
void drive() { System.out.println("Driving..."); }
}
Java Collections, Spring Framework & Spring Boot - Detailed Guide
@Component
class Person {
@Autowired Car car;
void travel() { car.drive(); }
}
11. Spring AOP & Bean Scopes
@Aspect
class Logger {
@Before("execution(* service.*.*(..))")
void log() { System.out.println("Log before call"); }
}
@Scope("prototype")
12. Spring Autowiring, Annotations, Lifecycle
- XML Configuration
- Annotation-based Configuration
- Java-based Configuration
@Configuration
class AppConfig {
@Bean
Car car() { return new Car(); }
}
14. Spring Boot Build Systems & Code Structure
Code Structure:
src/main/java
src/main/resources
15. Spring Boot Runner, Logger, and REST API
@SpringBootApplication
class App implements CommandLineRunner {
Java Collections, Spring Framework & Spring Boot - Detailed Guide
@RestController
class Hello {
@GetMapping("/hi")
public String greet() { return "Hello"; }
}
16. Request Mapping, RequestBody, PathVariable, RequestParam
@GetMapping("/item")
@PostMapping("/add")
@PutMapping("/update")
@DeleteMapping("/delete")