🔗 Day 17: LinkedList in Java Today, I explored LinkedList in Java, an important data structure that allows dynamic insertion and deletion of elements efficiently. 💡 What I Learned Today LinkedList is part of the java.util package. It implements both List and Deque interfaces. Elements are stored as nodes, each linked to the next and previous ones. Fast insertion and deletion, slower random access compared to ArrayList. Can be used as List, Queue, or Deque. 🧩 Example Code import java.util.LinkedList; public class LinkedListDemo { public static void main(String[] args) { LinkedList<String> names = new LinkedList<>(); names.add("Raj"); names.add("Arun"); names.addFirst("Kumar"); names.addLast("Devi"); System.out.println("LinkedList: " + names); names.removeFirst(); names.removeLast(); System.out.println("After removal: " + names); } } ⚔️ Difference Between ArrayList and LinkedList ArrayList → Best for random access. LinkedList → Best for frequent insertions or deletions. 🗣️ LinkedIn Caption 🔗 Day 17 – Understanding LinkedList in Java Learned how LinkedList stores data in connected nodes and shines in insertion/deletion tasks. Also explored how it differs from ArrayList in speed and structure. Another key milestone in my #30DaysOfJava journey 🚀 #Java #CoreJava #LinkedList #LearnJava #Programming
"Exploring LinkedList in Java: Efficient Insertion and Deletion"
More Relevant Posts
-
🔴 Java Basics – Wrapper Classes, Operators & Loops 🚀 ✅ Wrapper Classes :- In Java, wrapper classes are used to convert primitive data types into objects. For example, int can be converted into Integer, double into Double, etc. Wrapper classes are mainly useful when working with collections, because collections can store only objects. 🎯 They also support autoboxing and unboxing, which makes code cleaner and easier to write. ✅ Operators in Java :- Operators are symbols used to perform operations on values and variables. Some commonly used operators are: Arithmetic operators like + , - , * , / Relational operators like > , < , == Logical operators like && , || Assignment operators like = , += Unary operators like ++ , -- 🎯 Operators help in calculations, comparisons, and decision-making in Prog. ✅ Loops in Java :- Loops are used to execute a block of code multiple times. There are two main types: 1️⃣ Entry-controlled loops like for and while, where the condition is checked before execution. 2️⃣ Exit-controlled loop like do-while, where the loop runs at least once because the condition is checked after execution. 🎯 Loops are very useful for tasks like array traversal and repetitive logic. 💻 Practiced code uploaded on GitHub 👇 https://lnkd.in/g9hnWifj ❓ Interview Question: Why does a do-while loop execute at least once? #Java #CoreJava #JavaBasics #Programming #InterviewPreparation #LearningJourney
To view or add a comment, sign in
-
Mastering Wrapper Classes in Java: Converting Primitives to Objects If you are working with Java, you’ve likely used both int and Integer. But do you know why Java provides both? In Java, Wrapper Classes provide a way to use primitive data types (int, boolean, etc.) as objects. This is essential when working with Collections (like ArrayList or HashMap), which can only store objects, not primitives. The 8 Wrapper Classes Each primitive type has a corresponding wrapper class: Integer for int Double for double Character for char Boolean for boolean Float for float Long for long Byte for byte Short for short Key Concepts to Remember: 1. Autoboxing: The automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes (e.g., converting int to Integer). 2. Unboxing: The reverse process—converting an object of a wrapper class back to its corresponding primitive type (e.g., Integer to int). Why do we need them? Collections Framework: List, Set, and Map require objects. Utility Methods: Wrapper classes provide useful methods for conversion (like Integer.parseInt()). Null Values: Objects can be null, whereas primitives always have a default value. Understanding these fundamentals is a huge step toward becoming a proficient Java developer! #Java #JavaProgramming #FullStackDeveloper #BackendDevelopment #CodingTips #SoftwareEngineering #LearningJava #JavaDeveloper #TechEducation #WrapperClasses
To view or add a comment, sign in
-
-
𝙩𝙝𝙞𝙨 and 𝙨𝙪𝙥𝙚𝙧 keyword in java: 𝗣𝗼𝗶𝗻𝘁𝘀 𝘁𝗼 𝗿𝗲𝗺𝗲𝗺𝗯𝗲𝗿 In Java, 𝙩𝙝𝙞𝙨 and 𝙨𝙪𝙥𝙚𝙧 are reference keywords used to manage object behavior clearly and avoid ambiguity. => 𝙩𝙝𝙞𝙨 refers to the current object of the class. • It is mainly used to differentiate instance variables(variables declared inside class) from local variables, call current class methods, and chain constructors using this(). 𝗞𝗲𝘆 𝗽𝗼𝗶𝗻𝘁𝘀: • Refers to current class object • Used to avoid variable shadowing • Cannot be used in static context • Supports constructor chaining 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝘤𝘭𝘢𝘴𝘴 𝘗𝘦𝘳𝘴𝘰𝘯 { 𝘚𝘵𝘳𝘪𝘯𝘨 𝘯𝘢𝘮𝘦; 𝘗𝘦𝘳𝘴𝘰𝘯(𝘚𝘵𝘳𝘪𝘯𝘨 𝘯𝘢𝘮𝘦) { 𝘵𝘩𝘪𝘴.𝘯𝘢𝘮𝘦 = 𝘯𝘢𝘮𝘦; } } ===================================================== => 𝙨𝙪𝙥𝙚𝙧 refers to the parent class object. • It is used in inheritance to access parent class variables, methods, and constructors. 𝗞𝗲𝘆 𝗽𝗼𝗶𝗻𝘁𝘀: • Refers to immediate parent class • Used during method overriding • super() calls parent constructor • Must be first statement in constructor 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: 𝘤𝘭𝘢𝘴𝘴 𝘗𝘢𝘳𝘦𝘯𝘵 { 𝘪𝘯𝘵 𝘹 = 10; } 𝘤𝘭𝘢𝘴𝘴 𝘊𝘩𝘪𝘭𝘥 𝘦𝘹𝘵𝘦𝘯𝘥𝘴 𝘗𝘢𝘳𝘦𝘯𝘵 { 𝘪𝘯𝘵 𝘹 = 20; 𝘷𝘰𝘪𝘥 𝘴𝘩𝘰𝘸() { 𝘚𝘺𝘴𝘵𝘦𝘮.𝘰𝘶𝘵.𝘱𝘳𝘪𝘯𝘵𝘭𝘯(𝘹); // 20 𝘚𝘺𝘴𝘵𝘦𝘮.𝘰𝘶𝘵.𝘱𝘳𝘪𝘯𝘵𝘭𝘯(𝘴𝘶𝘱𝘦𝘳.𝘹); // 10 } } 𝗤𝘂𝗶𝗰𝗸 𝗱𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲: • this → current class • super → parent class • this() → current constructor • super() → parent constructor ✨ Follow for more 𝗝𝗮𝘃𝗮 & 𝗕𝗮𝗰𝗸𝗲𝗻𝗱 concepts! #Java #CoreJava #OOP #JavaInterview #BackendDevelopment #SpringBoot #SoftwareEngineering
To view or add a comment, sign in
-
. 📌 Day 80 — Understanding HashMap in Java Today I learned about HashMap, one of the most powerful and commonly used data structures in Java. It stores data in the form of key–value pairs, allowing fast access, insertion, and deletion. 🔹 What is a HashMap? A HashMap is part of Java’s java.util package and is implemented using a hash table. It allows us to store unique keys, each mapped to a specific value. It provides O(1) average time complexity for basic operations like: put() get() remove() containsKey() 🔹 Key Features ✔ Stores key–value pairs ✔ No duplicate keys allowed ✔ Allows null key and null values ✔ Order is not guaranteed ✔ Fast lookup due to hashing 🔹 Commonly Used Methods put(key, value) → Insert or update a value get(key) → Retrieve value by key remove(key) → Delete a key-value pair containsKey(key) → Check if a key exists keySet() → Returns all keys values() → Returns all values entrySet() → Returns all entries (key + value) 🔹 Where HashMap is Used? Caching systems Counting frequencies (word count, character count) Fast lookup tables Database-like key-value storage Managing configurations/settings 🎯 Summary HashMap is a highly efficient and flexible data structure that provides extremely fast access to data using keys. It’s widely used in real-world applications due to its performance and ease of use. #Java #HashMap #CollectionAPI #CodeWithBrahmaiah
To view or add a comment, sign in
-
-
Java Bytes #2 Code: class Main { public static void main(String[] args) { String String = "String"; System.out.println(String); } } The below will be the output... String This is a valid code because all the predefined class names in Java can be used as identifier names. Only keywords can't be used as identifiers. But it is a good practice to follow the naming conventions as below. 1. class/interface names with capital letter for each word(PascalCase). Eg: Runnable, StudentDto 2. method/variable names with small letter for the starting word followed by capital letter(camelCase). Eg: student, employeeRecord 3. constant names with full capital letters(UPPER_SNAKE_CASE). Eg: MAX_VALUE, MAX_RETRIES 4. package names with all lower case letters. Eg: java.util, java.lang What will be the output for the following code? class Main { public static void main(String[] args) { String String = "String"; String Main = "Main"; String main = "main"; String System = "System"; String out = "out"; String println = "println"; System.out.println(String); System.out.println(Main); System.out.println(main); System.out.println(System); System.out.println(out); System.out.println(println); } } If it is not giving the right output, what is the issue? ----------------- Java is like my girlfriend. I have misunderstood her many times. Still I try to understand her a lot. Please feel free to correct me if I have misunderstood her. #javaBytes #javaIsLove #javaInterviewPrep
To view or add a comment, sign in
-
#javaForAutomationDays _Day 4, 🔹What Are Variables in Java? Variables are memory locations used to store values that can change during the execution of a program. Every variable in Java has a type, a name, and a value. 🔹 Types of Variables in Java 1- Local Variables Declared inside methods or blocks and only accessible within that specific scope. They must be initialized before use. 2- Instance Variables Declared inside a class but outside any method. Each object has its own copy, and they receive default values if not initialized. 3- Static Variables (Class Variables) Declared using the keyword static and shared across all objects of the class, meaning there is only one shared copy. 🔹 Data Types in Java Java provides primitive data types such as: int, long, byte, short for whole numbers float, double for decimal numbers char for characters boolean for true/false values The most commonly used non-primitive type is String. 🔹 Quick Examples int age = 20; double salary = 4500.75; char grade = ‘A’; boolean active = true; String language = “Java”; 🔹 Variable Naming Rules A variable name must start with a letter, $, or _, and cannot start with a number. Names are case-sensitive, and it’s recommended to use camelCase with meaningful names. 🔹 Why Are Variables Important? They allow programs to store and manage data dynamically, making the code flexible, reusable, readable, and easier to maintain. #java #softwaretesting #programming #Techlearnin
To view or add a comment, sign in
-
-
Day-39 Collections in Java 👩💻 Today, I started learning one of the most important part of Java — the Collections Framework, which plays a huge role in writing efficient, clean, and scalable code. 📍 𝐖𝐡𝐚𝐭 𝐈𝐬 𝐚 𝐂𝐨𝐥𝐥𝐞𝐜𝐭𝐢𝐨𝐧? A Collection is an object that can hold multiple elements together as a single unit. Instead of managing many separate variables, collections allow us to work with data as a group. 👉 Examples: ● List of student names ● Set of unique IDs In Java, Collection itself is an interface available in the 𝐣𝐚𝐯𝐚.𝐮𝐭𝐢𝐥 𝐩𝐚𝐜𝐤𝐚𝐠𝐞. 📘 𝐖𝐡𝐚𝐭 𝐈𝐬 𝐭𝐡𝐞 𝐂𝐨𝐥𝐥𝐞𝐜𝐭𝐢𝐨𝐧 𝐅𝐫𝐚𝐦𝐞𝐰𝐨𝐫𝐤? The Collections Framework (Collection API) is a unified architecture provided by Java to: ● Store data ● Manipulate data ● Access data efficiently It consists of: ● Interfaces → List, Set, Queue, Map ● Implementations → ArrayList, LinkedList, HashSet, TreeSet, HashMap, etc. This framework makes data handling consistent and flexible across applications. 📍 𝐂𝐨𝐥𝐥𝐞𝐜𝐭𝐢𝐨𝐧 𝐯𝐬 𝐂𝐨𝐥𝐥𝐞𝐜𝐭𝐢𝐨𝐧𝐬 🔹Collection → An interface that represents a group of objects 🔹Collections → A utility class that provides static helper methods 👉 Examples of what Collections helps with: ➖ Sorting data ➖ Reversing order ➖ Finding min/max values ➖ Shuffling elements ❓ Why do we need Collections? Before collections, we used arrays, but arrays have limitations: ❌ Fixed size ❌ Cannot grow or shrink ❌ Limited built-in methods ✅ Collections solve these problems by providing: ➖ Dynamic size ➖ Ready-made methods (add, remove, search, sort) ➖ Better performance and flexibility ✅ When to use what? Use List → when order & duplicates matter Use Set → when uniqueness is required Use Queue → when processing order matters Use Map → when data is in key-value form #10000Coders Gurugubelli Vijaya Kumar #java #core java #Dailylearning
To view or add a comment, sign in
-
-
📘 Java Learning | transient vs @Transient (Real-Time Example) Today I learned a very important Java concept that often creates confusion in real projects and interviews 👇 🔹 transient (Core Java) transient is a Java keyword Used to exclude a variable from serialization When an object is converted into a byte stream, transient fields are NOT saved 👉 After deserialization, these fields get default values: null → Objects 0 → Numbers false → Boolean class User implements Serializable { String username; transient String password; } 📌 Real-time use case: Passwords, OTPs, session data should never travel over the network or be stored in files. 🔹 @Transient (JPA / Hibernate) @Transient is a JPA annotation It tells Hibernate NOT to persist the field in the database The field exists only in memory, not in DB tables 🖼️ Image Explanation: The attached image shows: How sensitive fields are skipped during serialization How transient values become default after deserialization How @Transient fields are never stored in DB 📌 Key Takeaway: ✔ transient → controls serialization ✔ @Transient → controls database persistence ✔ Knowing this difference is crucial for real-time projects & interviews #Java #CoreJava #SpringBoot #Hibernate #JPA #BackendDevelopment #JavaDeveloper #Serialization #ProgrammingConcepts #DailyLearning #SoftwareEngineering
To view or add a comment, sign in
-
-
Understanding Java’s Object Class – The 11 Essential Methods Every Developer Should Know In Java, everything starts with Object. Every class implicitly extends the Object class, which provides 11 powerful utility methods that allow us to add, modify, compare, clone, manage threads, and handle runtime behavior effectively. These methods form the foundation of object manipulation in real-time Java applications. The 11 Methods of Java’s Object Class 1. toString() Returns a string representation of the object (useful for logging & debugging). 2. hashCode() Generates a hash value—important for HashMap, HashSet, etc. 3. equals(Object obj) Checks if two objects are logically equal. 4. clone() Creates a copy of the object (shallow copy). 5. getClass() Returns the runtime class information. 6. finalize() Called by the Garbage Collector (deprecated now, but part of the original 11). 7. wait() Causes the current thread to wait until another thread calls notify(). 8. wait(long timeout) Waits for a specific time. 9. wait(long timeout, int nanos) Waits with nano-second precision. 10. notify() Wakes up one waiting thread. 11. notifyAll() Wakes up all waiting threads. How These Methods Help in Real-Time Applications Modify data at runtime using clone() and equals() Manage concurrency with wait(), notify(), and notifyAll() Improve debugging with a custom toString() Optimize collections with equals() and hashCode() Perform runtime inspections using getClass() 10000 Coders #100DaysofCode #Day31 #Java #Methods #codingJourney #LearningEveryDay
To view or add a comment, sign in
-
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