🚀 Learning Update: Sorting Custom Objects Using ArrayList in Java Today I worked on an interesting Java concept — sorting custom objects stored in an ArrayList. In real-world applications, we often deal with objects like Students, Employees, or Products instead of primitive data types. Learning how to sort these objects efficiently is an important skill for writing clean and scalable code. 🔹 What I learned: ✅ Creating a custom class with attributes ✅ Storing objects inside an ArrayList ✅ Sorting objects using Comparator with lambda expressions ✅ Writing cleaner and more readable Java code Here’s a simple example I practiced: 💡 Key takeaway: Java provides powerful tools like Comparator and lambda expressions that make sorting objects flexible and easy without modifying the original class. Every day learning something new and strengthening my Java fundamentals 💻✨ #Java #Programming #LearningJourney #SoftwareDevelopment #JavaDeveloper #Coding #Collections #OOP
Sorting Custom Objects in Java with Comparator and Lambda
More Relevant Posts
-
🚀 I completed Day 3 of my Java learning using the W3Schools platform.Today, I studied about java Operators, Strings, and Type Casting.” This helped me understand how Java handles data transformation and manipulation. First, I learned about Type Casting, which is used to convert one data type into another. I understood that Java is a strictly typed language, so data must be converted carefully when moving between different types. I also learned about automatic casting (widening) such as converting "int" to "double", and manual casting (narrowing) where a larger type like "double" is converted to a smaller type like "int", which may cause loss of decimal values. Next, I explored operators in Java, which act as the logic engine of a program. These include arithmetic operators ("+ - * / %"), assignment operators, comparison operators ("==, >, <, >=, <="), and logical operators ("&&, ||, !"). I also learned how the “+” operator can be used not only for arithmetic calculations but also for string concatenation. Another important concept I studied was Strings in Java. I learned that strings are objects with built-in methods that allow us to analyze and manipulate text. Some useful string methods include "length()", "charAt()", "indexOf()", and "toUpperCase()" which help in processing text data effectively. Finally, I saw how these concepts work together in a practical example where operators, type casting, and string concatenation are used to calculate and display a score percentage in a program. #Java #Programming #LearningJourney #SoftwareDevelopment #W3schools
To view or add a comment, sign in
-
Java Learning Journey – Day 5 Today I explored one of the most commonly used concepts in Java — Strings. Strings are used to store and manipulate text data, and almost every Java application uses them in some way. 🔹 Key things I learned today: • Creating Strings – String name = "Java Learner"; • Concatenation – Joining two strings together using + • Finding Length – Using length() to know the size of a string • Accessing Characters – Using charAt() 🔹 Useful String Methods: • toUpperCase() / toLowerCase() – Change letter case • indexOf() / contains() – Search inside strings • substring() – Extract part of a string • replace() – Replace text • split() – Break string into parts • trim() – Remove extra spaces 💡 Why Strings are important? Because most real-world applications deal with text processing, user input, and data handling. Learning step by step and building a strong foundation in Java every day. If you're learning Java or working in development, feel free to connect and share your journey. 🤝 #Java #JavaDeveloper #Programming #CodingJourney #SoftwareDevelopment #LearnJava
To view or add a comment, sign in
-
-
🚀 Learning Method Chaining in Java Today in my Java training, I learned about Method Chaining in Java. Method chaining means calling multiple methods one after another using the same object in a single line of code. This makes the code shorter, cleaner, and easier to understand. For example, in the image you can see how an object is created and then different methods are called continuously like ".setMake() → .setModel() → .setYear()". Concepts like this help us write better and more structured Java programs. Every day in training I’m learning new things that are helping me strengthen my Core Java fundamentals. Sharing this small learning from today. #Java #CoreJava #JavaDeveloper #Programming #Coding #LearningJourney #cimagecollege #Qspidernoida #ai #concepts
To view or add a comment, sign in
-
-
🚀 Day 29 | Core Java Learning Journey 📌 Topic: TreeSet in Java Today, I learned about TreeSet, an important class in the Java Collections Framework used when we need sorted and unique elements. 🔹 TreeSet in Java ✔ TreeSet is a class that implements NavigableSet ✔ It also indirectly implements SortedSet and Set ✔ Introduced in JDK 1.2 ✔ Stores unique elements only (no duplicates allowed) 🔹 Data Structure Used ✔ Based on Self-Balancing Binary Search Tree (Red-Black Tree) ❗ (important correction) ✔ Elements are stored in sorted order 🔹 Key Features ✔ Does NOT follow insertion order ✔ Follows natural sorting order (default) ✔ Allows custom sorting using Comparator ✔ Does NOT allow null elements ❌ ✔ Stores homogeneous data (same type, for proper comparison) 📌 Important Methods • add() – add element • remove() – delete element • contains() – check element • first() – returns first (smallest) element • last() – returns last (largest) element • higher() – next greater element • lower() – next smaller element 📌 Performance ✔ Operations like add, remove, search → O(log n) 📌 When to Use TreeSet? ✔ When you need: ✅ Sorted data ✅ Unique elements ✅ Range-based operations 💡 Note: Unlike HashSet, TreeSet focuses on sorting rather than speed. 🙏 Special thanks to Vaibhav Barde Sir for the guidance! 🔥 #CoreJava #JavaLearning #JavaDeveloper #TreeSet #SortedSet #NavigableSet #JavaCollections #Programming #LearningJourney
To view or add a comment, sign in
-
-
🚀 Java Learning Journey – Interesting Concept While learning Java, I came across an important concept: 👉 Why is String immutable in Java? In Java, once a String object is created, its value cannot be changed. This design helps Java in several ways: • Improves security for sensitive data • Enables String Pool for memory optimization • Provides thread safety in multi-threaded environments • Ensures better performance when used as keys in HashMap Understanding these core concepts helps build a stronger foundation in Java development. What other Java concepts do you think every developer should know? #Java #JavaDeveloper #Programming #Coding #SoftwareDevelopment #LearningInPublic
To view or add a comment, sign in
-
🚀 Starting My Java Learning Journey – Day 10 🔹 Topic: Recursion in Java Recursion is a process where a method calls itself to solve a problem. It is mainly used to break down complex problems into smaller, simpler sub-problems. A recursive function must have: ✔ Base Case → condition to stop recursion ✔ Recursive Call → method calling itself Example: Factorial of a Number public class Main { static int factorial(int n) { if (n == 1) { // base case return 1; } return n * factorial(n - 1); // recursive call } public static void main(String[] args) { int result = factorial(5); System.out.println("Factorial: " + result); } } Output: Factorial: 120 ✔ Recursion solves problems by calling the same method repeatedly ✔ Every recursive method must have a base case ✔ Useful for problems like factorial, Fibonacci, tree traversal #Java #JavaLearning #Programming #BackendDevelopment #CodingJourney #Recursion
To view or add a comment, sign in
-
🚀 Day – Java Learning Update ⏳ 🎯 Understanding Looping Statements: For Loop in Java Today, I learned about Looping Statements in Java, specifically the for loop. Loops help execute a block of code multiple times without writing the same code repeatedly. What is a For Loop? A for loop is used when the number of iterations is known in advance. It combines initialization, condition, and increment/decrement in a single statement. Initialization – starting point of the loop Condition – determines how long the loop runs Increment/Decrement – updates the loop variable Syntax of For Loop: for(initialization; condition; increment/decrement) { // code to execute repeatedly } Task: Find the factorial of a num from 1 to 30 #Java #JavaFullStack #CoreJava #ForLoop #Programming #SoftwareDeveloper #BackendDeveloper #LearningJourney 10000 Coders Meghana M
To view or add a comment, sign in
-
-
🚀 Starting My Java Learning Journey – Day 6 🔹 Topic: Loops in Java Loops in Java are used to execute a block of code repeatedly until a certain condition is met. Java mainly provides three types of loops: 1️⃣ for Loop Used when the number of iterations is known. Example: public class Main { public static void main(String[] args) { for(int i = 1; i <= 5; i++) { System.out.println(i); } } } 2️⃣ while Loop Used when the number of iterations is not known beforehand. Example: public class Main { public static void main(String[] args) { int i = 1; while(i <= 5) { System.out.println(i); i++; } } } 3️⃣ do-while Loop The do-while loop executes the code at least once even if the condition is false. Example: public class Main { public static void main(String[] args) { int i = 1; do { System.out.println(i); i++; } while(i <= 5); } } 💡 Key Point: Loops help automate repetitive tasks and make programs more efficient. #Java #JavaLearning #Programming #BackendDevelopment #CodingJourney #JavaLoops
To view or add a comment, sign in
-
Today’s Learning Update ✅ (Core Java — Strings) In today’s session, I learned one of the most important foundational topics in Java: Strings — how they are created, stored in memory, compared, and concatenated. 📌 Key Learnings: ✅ What is a String in Java? A String is a sequence/collection of characters enclosed in double quotes (" "). Also, Strings are objects in Java. ✅ Types of Strings Immutable String → cannot be changed (created using String class) Mutable String → can be changed (covered briefly; will be explored further) ✅ Ways to create an Immutable String Using new keyword Without new (String literal) Using char[] array and converting to String ✅ String Memory Concept (Very Important!) Java allocates String memory in two places inside Heap: String Constant Pool (SCP) → created without new, duplicates not allowed Heap Area → created with new, duplicates allowed ✅ Comparing Strings == → compares references (address) .equals() → compares values .equalsIgnoreCase() → compares values ignoring case .compareTo() → compares character by character (covered for later) ✅ String Concatenation Using + operator Using .concat() method ⚡ Important insight: + with two string literals → goes to SCP + with references → goes to Heap .concat() → always creates result in Heap 🧠 This session made me understand why String fundamentals are asked frequently in interviews, especially around == vs equals() and SCP vs Heap behavior. #Java #CoreJava #Strings #Programming #DSA #Learning #InterviewPreparation #SoftwareDevelopment #Coding TAP Academy
To view or add a comment, sign in
-
-
Day 11of Learning Java Topic: Pattern Programs in Java Today I practiced pattern programs using loops. Pattern programs help us understand loops and logic better. We use nested loops to print shapes like stars, numbers, or letters. How It Works Outer loop → controls the rows Inner loop → prints stars in each row Step by step: Row 1 → 1 star Row 2 → 2 stars Row 3 → 3 stars Row 4 → 4 stars Row 5 → 5 stars
To view or add a comment, sign in
-
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Great progress Yuvaraj G! Love seeing people invest in learning Java and growing their skills. If you’re looking for structured practice, feel free to check out our free course: https://www.javapro.academy/bootcamp/the-complete-core-java-course-from-basics-to-advanced/ Keep up the awesome work!