💻 Java Practice Update I wrote a program to check if brackets in a string are balanced using the Stack data structure in Java. It ensures that every opening bracket (, {, [ has a proper closing pair ), }, ] in the correct order. 🔍 Methods Used: push() → Adds an element (opening bracket) to the stack. pop() → Removes the top element when a matching closing bracket is found. peek() → Checks the top element without removing it, to verify if it matches the closing bracket. isEmpty() → Ensures that all brackets are properly closed by the end of the string. 🧩 Example: Input → {()} Output → true ✅ This exercise helped me understand how stack operations work behind the scenes and how useful they are in solving real-world problems like expression validation and syntax checking. #Java #CodingPractice #Stack #ProblemSolving #Programming #LearningEveryday #DataStructures 10000 Coders karunakar pusuluri Usha Sri
Balanced Brackets in Java using Stack
More Relevant Posts
-
My journey of Java coding begins now Today I wrote the first java program import java.util.*; public class addtwonumbers(){ public static void main(String [] ARGS){ System.out.println( "Enter two numbers"); Scanner sc = new Scanner (System.in); int a = sc.nextInt(); int b = sc.nextInt(); int sum = a+b; System.out.println("Sum of two numbers"+sum) sc.close(); } explanation: util is a package for using scanner class we are creating scanner named sc. system.in => means we are taking input from the user This line asks the user to enter the first number. Then sc.nextInt() listens and saves that number into a box named a Again, Java listens for the next number and stores it in another sticky note labeled b Java now prints the final answer on the screen. Analogy: It’s like the cashier announcing your total amount Open for any suggestions #Java #Coding #DailyLearning #AWS #LinkedIn #Python #Selenium #AutomationTesting #Restapi #Programming
To view or add a comment, sign in
-
🔹 Static vs Non-Static in Java In Java, understanding the difference between static and non-static is essential for writing efficient, object-oriented code. 💡 Static: Belongs to the class, not to any specific object. Can be accessed directly using the class name. Memory is allocated only once, when the class is loaded. Commonly used for utility methods, constants, or shared data. 💡 Non-Static: Belongs to an instance of the class. Requires creating an object to access. Each object has its own copy of non-static variables. Used when behavior or data differs per object. 💬 Mastering this concept helps in better memory management and cleaner code design. Thank you to Anand Kumar Buddarapu Sir for explaining this concept clearly and guiding me through it! #Java #Programming #OOP #Coding #Learning
To view or add a comment, sign in
-
-
🚀 #Day52 of My Java Journey Today, I learned about Encapsulation — a core concept of Object-Oriented Programming in Java. 𝐄𝐧𝐜𝐚𝐩𝐬𝐮𝐥𝐚𝐭𝐢𝐨𝐧 means Binding the data (variables) and methods into a single unit(Class), while controlling access to that data. 🔒𝙒𝙝𝙮 𝙀𝙣𝙘𝙖𝙥𝙨𝙪𝙡𝙖𝙩𝙞𝙤𝙣: 𝑫𝒂𝒕𝒂 𝑯𝒊𝒅𝒊𝒏𝒈: The variables are kept private, so they cannot be accessed directly from outside. 𝑪𝒐𝒏𝒕𝒓𝒐𝒍𝒍𝒆𝒅 𝑨𝒄𝒄𝒆𝒔𝒔: We access or modify data only through getter & setter methods. 𝑺𝒆𝒄𝒖𝒓𝒊𝒕𝒚: Improves security by hiding sensitive data 𝑴𝒂𝒊𝒏𝒕𝒂𝒊𝒏𝒂𝒃𝒊𝒍𝒊𝒕𝒚: Implementation can change without affecting other classes 𝑹𝒆𝒖𝒔𝒂𝒃𝒊𝒍𝒊𝒕𝒚: Well-encapsulated classes are easier to reuse 𝙃𝙤𝙬 𝙩𝙤 𝘼𝙘𝙝𝙞𝙚𝙫𝙚 𝙀𝙣𝙘𝙖𝙥𝙨𝙪𝙡𝙖𝙩𝙞𝙤𝙣: 👉Declare variables as private 👉Use public setters and getters to update or read the data This helped me understand how encapsulation not only hides data but also allows us to validate and protect it before storing ✅ 10000 Coders #Java #OOP #Encapsulation #LearningJourney #ProblemSolving #JavaProgramming
To view or add a comment, sign in
-
-
♻️ Garbage Collection in Java — Simplified! 🚀 In Java, memory management is handled automatically using a process called Garbage Collection (GC). It removes objects that are no longer in use, keeping your application memory-efficient and stable! 💡 🧠 How it works: obj1 and obj2 are made null, so they’re no longer referenced. System.gc() requests the JVM to perform Garbage Collection. Before destroying an object, the JVM automatically calls the finalize() method. Adding a small delay (Thread.sleep(1000)) helps give the JVM time to trigger GC before the program exits. ✅ Sample Output: Garbage collector called for object: GarbageCollector@6bc7c054 Garbage collector called for object: GarbageCollector@232204a1 Main method completed Java’s Garbage Collector ensures that memory is managed efficiently — so developers can focus on logic, not cleanup! 💪 #Java #GarbageCollection #Programming #JavaDeveloper #Coding #TechLearning
To view or add a comment, sign in
-
-
♻️ Garbage Collection in Java — Simplified! 🚀 In Java, memory management is handled automatically using a process called Garbage Collection (GC). It removes objects that are no longer in use, keeping your application memory-efficient and stable! 💡 🧠 How it works: obj1 and obj2 are made null, so they’re no longer referenced. System.gc() requests the JVM to perform Garbage Collection. Before destroying an object, the JVM automatically calls the finalize() method. Adding a small delay (Thread.sleep(1000)) helps give the JVM time to trigger GC before the program exits. ✅ Sample Output: Garbage collector called for object: GarbageCollector@6bc7c054 Garbage collector called for object: GarbageCollector@232204a1 Main method completed Java’s Garbage Collector ensures that memory is managed efficiently — so developers can focus on logic, not cleanup! 💪 #Java #GarbageCollection #Programming #JavaDeveloper #Coding #TechLearning
To view or add a comment, sign in
-
-
💻 Java Practice: Character Frequency Counter using HashMap Today, I practiced a simple but powerful Java program — counting the frequency of each character in a string using the HashMap collection. This concept helped me understand how Map, containsKey(), and entrySet() work together to store and iterate over key–value pairs efficiently. 🧠 Logic Used: Take input from the user (a string). Convert it into a character array. For each character: If it’s already in the map → increment the count. Else → add it with count = 1. Finally, print each character with its frequency using entrySet(). 💡 Example: Input → banana Output → b = 1 a = 3 n = 2 This small program strengthens understanding of the Collections Framework, especially Map and Entry interfaces. 🧩 Key Learnings: Efficient data counting using HashMap Iterating entries with entrySet() Practical use of conditional checks (containsKey) Small programs build strong logic. Keep coding every day! 🚀 #Java #Coding #DSA #Collections #HashMap #JavaDeveloper #Programming #LearnByDoing #CodeEveryday #TechLearning
To view or add a comment, sign in
-
-
📐 Java Hypotenuse Calculator – Quick Geometry in Action! Built a simple yet efficient Java console application that calculates the hypotenuse of a right-angled triangle using the Pythagorean theorem. This project helped me practice user input handling, mathematical operations, and output formatting in Java. ⚙️ Features: • Accepts side lengths A and B as user input • Calculates the hypotenuse C using Math.sqrt() and Math.pow() • Displays the result with two-decimal precision 🧠 Concepts used: Scanner class, Java Math library, and basic geometry 🔧 Tools in use: Java SE, IntelliJ IDEA / VS Code 🎯 Goal: Strengthen Java fundamentals while applying mathematical logic to real-world problems GitHub: https://lnkd.in/dUJEkMPg #JavaDevelopment #JavaProjects #ConsoleApplication #SoftwareEngineering #CodingProjects #Programming #LearningByDoing #BeginnerProjects #CodeNewbie #DeveloperJourney #ObjectOrientedProgramming #JavaCommunity
To view or add a comment, sign in
-
After understanding why Java is important, today I explored the absolute basics — 👉 What is a Program? A set of instructions to solve a real-world problem. 👉 What is Programming? The skill of writing those instructions effectively. But here’s the real eye-opener 💡 Programming isn’t just about writing code — it’s about fixing errors! If I want my code to run smoothly, I first need to identify its three biggest enemies: ⚙️ 1. Compile Time Error (The Grammar Check) Occurs before execution. It’s all about syntax mistakes — missing semicolons, misspelled keywords, etc. 💡 Compiler (like javac) catches these right away — so always pay attention to syntax! 💥 2. Runtime / Execution Error (The Unexpected Crash) Happens during execution. Your code is syntactically correct, but something unexpected happens — dividing by zero, accessing invalid indexes, etc. These usually trigger Exceptions. 🧠 3. Logical Error (The Silent Killer) The hardest one to spot. Your program compiles and runs but gives wrong results — because your logic is flawed. 🎯 My Takeaway: Understanding these errors helps me structure my testing process better and build stronger debugging habits. 💬 Which of these errors frustrated you the most when you were learning Java? Share your war stories below! 👇 #Java #ProgrammingBasics #CoreJava #LearningJourney #QSpiders #JSpiders #CompileTimeError #RuntimeError #LogicalError #SineshBabbar
To view or add a comment, sign in
-
-
🚀 Day 68 – Java Collections Deep Dive (ArrayList with Custom Objects) Today, I worked on an interesting concept in Java: Using ArrayList to store and filter custom objects (Student class). Here’s what I implemented: 🔵 Created a Student class with fields → ID, Name, Age, Marks 🔵 Stored multiple Student objects inside an ArrayList 🔵 Printed all records using an enhanced for-each loop 🔵 Used removeIf() with Lambda Expressions to filter data based on dynamic conditions • 🔵 Remove students with marks < 85 • 🔵 Remove students with age < 25 • 🔵 Remove students with name length < 3 ✨ Key Takeaway: Modern Java features like Lambdas + Collection API make filtering and processing object lists extremely clean, readable, and powerful. Feeling great progressing one step at a time! More concepts loading… 🔥 10000 Coders Gurugubelli Vijaya Kumar #Day68 #Java #Collections #ArrayList #LambdaExpressions #CodingJourney #LearningInPublic #JavaDeveloper
To view or add a comment, sign in
-
Day 7 of #50DaysOfCode – Java Today I practiced arrays and conditional statements by writing a program to find the smallest number from five user inputs. 💻 What I did: Took 5 numbers from the user Stored them in an array Used a loop and if condition to find the smallest number 🧠 Concepts learned: Arrays (int[]) Loops (for) Conditional statements (if) Input/output using Scanner Step by step, getting stronger with Java! 💪 #Java #CodingJourney #LearnInPublic #Programming #50DaysOfCode
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
Very good keep practicing madulika all the best