Started learning Strings in Java today. After working with arrays and matrices, this felt like moving into how real programs actually handle text and user input. The focus was on understanding how strings are created, how input is taken, and how basic built-in methods like charAt() and length() work internally. String s = "Pratim"; System.out.println(s.charAt(0)); // Output : P System.out.println(s.length()); // Output : 6 What became clear today: - Strings are not primitive values; they behave like objects with built-in functionality - Accessing characters requires methods like charAt() instead of direct indexing - length() is a method call, not a property like in arrays - Even simple text handling introduces a different way of thinking compared to numbers This felt like the starting point of working with real-world data, where most problems involve text rather than just numbers. Beginning the Strings module today. #Java #DSA #Strings #LearningInPublic #ProblemSolving #CodingJourney #Programming #JavaDeveloper #DeveloperJourney
Java Strings Basics: Understanding String Creation and Methods
More Relevant Posts
-
📌 Arrays and Jagged Arrays in Java Hi Connections 👋 Understanding arrays is one of the first steps in learning Java properly. 🔹 What is an Array in Java? An array is a collection of elements of the same data type stored in continuous memory locations. ✔ Fixed size ✔ Same data type ✔ Access using index (starts from 0) 🔹 What is a 2D Array? >>A 2D array is like a table (rows and columns). >>Each row has the same number of columns. 🔹 What is a Jagged Array? >>A jagged array is a 2D array where each row can have a different number of columns. >>So the size of each row is different. 💡 Why use Jagged Arrays? Saves memory Useful when data is not uniform Common in real-world problems #Java #Arrays #JaggedArray #Programming #CodingJourney #LearnJava
To view or add a comment, sign in
-
-
Today I focused on understanding the types of variables in Java and how their behavior changes depending on where they are declared. At first it looked simple, but while going through examples, I realized that the real difference is not the datatype — it is the scope, initialization, and memory behavior of the variable. Things that became clear: - Local variables exist only inside methods, blocks, or constructors and must be initialized before use - Their scope is limited to the method in which they are declared - Instance variables are declared inside a class but outside methods and are automatically initialized with default values by the compiler - These default values depend on datatype, such as 0 for numeric types, false for boolean, '\0' for char, and null for objects - Instance variables are accessible across all methods of the same class, showing how objects maintain state Seeing the object example made the concept clearer, an object holds its own copy of instance variables, which get real values only after initialization. The biggest realization from this topic was simple - Understanding Java is less about syntax and more about how memory, scope, and initialization actually work. Small concept, but an important foundation for everything ahead. #java #programming #learninginpublic #javabasics #codingjourney
To view or add a comment, sign in
-
If you’re learning Java, understanding where variables live in memory is a game-changer 💡 Here’s a simple breakdown 👇 🔹 Instance Variable Declared inside a class, outside methods Belongs to an object Each object has its own copy Stored in Heap memory Gets default values (int → 0, String → null) 🔹 Static Variable Declared with static keyword Belongs to the class, not objects Only one copy shared by all objects Created when the class is loaded Stored in Method Area / Class Area 🔹 Local Variable Declared inside a method or block Works only within that method No default value Must be initialized before use Stored in Stack memory 📌 Memory Rule to Remember Local → Stack Instance → Heap Static → Method Area This concept is very important for: ✅ Interviews ✅ Writing optimized code ✅ Understanding JVM memory If you’re learning Java or revising fundamentals, save this post 🙌 #Java #JavaBasics #OOPs #Programming #JVM #Coding #SoftwareDevelopment #LearningJava
To view or add a comment, sign in
-
-
🚀 DSA in Java – Day 72 ✅ LeetCode Problem Solved: Subsets II 🔁 Concept Used: Backtracking + Recursion 🧠 Key Focus: Handling duplicate elements correctly Today I solved Subsets II, where the main challenge was generating all unique subsets from an array that may contain duplicates. 🔑 What I learned: Why sorting the array is important before recursion How to skip duplicates using this condition: if (idx > i && nums[idx] == nums[idx - 1]) continue; Proper backtracking steps (add → recurse → remove) How recursion builds subsets step by step Learning something new every day and getting better at problem-solving 💪 #DSA #Java #LeetCode #Backtracking #Recursion #ProblemSolving #CodingJourney #DailyLearning #Consistency
To view or add a comment, sign in
-
-
🚀 Day 10 – How Arrays Really Work in Java Today I went beyond basic syntax and understood how arrays actually work internally in Java. 🔎 What I explored: ✔️ How arrays are stored in contiguous memory locations ✔️ How index-based access works (0-based indexing) ✔️ How array size is fixed after creation ✔️ How reference variables point to array objects in memory ✔️ Time complexity of accessing elements – O(1) Understanding the internal working of arrays helped me realize why they are fast for accessing elements but limited when it comes to resizing. This concept is very important before moving to advanced data structures like ArrayList, LinkedList, and more. 🙏 Special thanks to Aditya Tandon Sir for explaining the internal memory concept so clearly. #Day10 #Java #Arrays #DataStructures #LearningJourney #Programming #Coding #JavaDeveloper
To view or add a comment, sign in
-
-
🚀 Day 4/30 – Java DSA Challenge 🔎 Problem 32: 1343. Number of Sub-arrays of Size K and Average ≥ Threshold (LeetCode – Medium) Today’s problem is a classic Sliding Window (Fixed Size) pattern 🔥 🧠 Problem Statement Given: An integer array arr An integer k (window size) An integer threshold We must return the number of subarrays of size k whose average ≥ threshold. 💡 Key Insight Instead of calculating average every time: 👉 We maintain a running window sum 👉 When window size becomes k, check: (sum/k)≥threshold Even better optimization: Instead of dividing every time, we can compare: sum≥k×threshold This avoids division and makes it faster. ⏱ Time Complexity O(n) → Each element enters and leaves the window once 📦 Space Complexity O(1) → No extra data structures used 📌 Key Learning Fixed-size sliding window avoids recalculating sums Converting average condition to sum comparison improves efficiency Medium problems often test pattern clarity, not complexity 32 Problems Completed 🔥 Day 4 Going Strong 💪🚀 #Day4 #30DaysOfCode #Java #DSA #LeetCode #SlidingWindow #Arrays #ProblemSolving #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Wrapping up the core concepts of the Strings module today. The final focus was on understanding what actually happens inside memory when strings are created and compared. Concepts like immutability, string interning, and the difference between == and .equals() made it clear that strings are not just simple text values, but structured objects with specific behavior. String a = "hello"; String b = "hello"; String c = new String("hello"); System.out.println(a == b); // true System.out.println(a == c); // false System.out.println(a.equals(c)); // true What became clear : - Strings in Java are immutable, meaning their value cannot be changed after creation - The string pool allows memory reuse when identical literals are created - "==" compares references, while ".equals()" compares actual content - Understanding memory behavior is essential for writing correct and efficient programs This felt like the point where Strings moved from simple syntax to real computer science understanding. Completed the core learning of the Strings module today. #Java #DSA #Strings #LearningInPublic #ProblemSolving #CodingJourney #Programming #JavaDeveloper #DeveloperJourney
To view or add a comment, sign in
-
🚀 Day 3/30 – Java DSA Challenge 🔎 Problem 27: 1876. Substrings of Size Three with Distinct Characters (LeetCode – Easy) Today’s problem combined Sliding Window + HashMap frequency tracking 🔥 🧠 Problem Statement A substring is called good if: ✔ Its length is 3 ✔ All characters are distinct Return the number of such substrings. Example: Input: "xyzzaz" Output: 1 Only "xyz" has all distinct characters. 💡 Approach Used – Sliding Window + HashMap Instead of checking every substring separately: ✔ Use window size k = 3 ✔ Maintain a HashMap<Character, Integer> to track frequency ✔ Expand window by adding characters ✔ Shrink window when size exceeds 3 ✔ If map size == 3 → all characters are distinct ⏱ Time Complexity: O(n) 📦 Space Complexity: O(1) – At most 3 characters in map 📌 Key Learning Practiced fixed-size sliding window Combined HashMap with two-pointer technique Understood how frequency map helps detect distinct characters 27 Problems Completed 🔥 Day 3 consistency going strong 💪🚀 #Day3 #30DaysOfCode #Java #DSA #LeetCode #SlidingWindow #HashMap #ProblemSolving #CodingJourney #Consistency
To view or add a comment, sign in
-
-
💡 Why does System.out.print(); sometimes give a compile-time error? While learning Java, you might write something like this: System.out.println("A"); System.out.print(); System.out.println("X"); and get a compile-time error. Why does this happen? 🤔 ✔️ The reason: System.out.print(); prints output without moving to a new line, but this method requires an argument. When you leave it empty, the compiler doesn’t know what it should print, so it throws a compile-time error. In simple words 👉 print() must be given something to print. ✔️ How to fix it: 📍 If you want a blank line: System.out.println(); 📍 If you want to print a space: System.out.print(" "); Small mistakes like this help us understand how Java methods really work 💻✨ What other small Java mistakes helped you understand programming better? Drop them in the comments 👇 #Java #Programming #LearningJava #CodingBasics #SoftwareEngineering
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