🚀 Learning Java Star Patterns and Pattern Logic Today I practiced some Java pattern programs using nested loops in VS Code and ran them using the command prompt (javac and java). Along with writing the code, I also tried to understand the logic behind each pattern. 1. X Pattern * * * * * * * * * • Use two nested loops for rows and columns. • Print * when the row number equals the column number (i == j). • Print * when the sum of row and column equals n + 1 (i + j == n + 1). • Otherwise print space. This creates two diagonals forming the X shape. 2.Inverted Triangle Pattern * ** *** **** ***** **** *** ** * • First loop prints stars increasing from 1 to n. • Second loop prints stars decreasing from n-1 to 1. • This combination creates a diamond-like pattern without spaces. 3.Alphabet Pattern – Letter D **** * * * * * * * * **** • First and last rows print continuous stars (****). • Middle rows print stars only at the first and last column. • Spaces are printed between them to form the shape of letter D. Grateful for the guidance from my mentors 🙏 Special thanks to: Dr. Tushar Ram Sangole sir Sushma Nair Mam Milind Ankleshwar sir #Java #Programming #CodingPractice #StarPatterns #LearningJava #ProblemSolving
Java Star Patterns and Pattern Logic with Dr Tushar Ram Sangole
More Relevant Posts
-
Day 40 of Learning Java: Method Overloading Instead of creating different method names for similar tasks, we can use the same method name but change the parameters — and Java figures out which one to call. -So what exactly is Method Overloading? It’s when multiple methods in the same class have: ✔ Same name ✔ Different parameter list That’s it. Simple idea, but very powerful. -Ways to overload a method • Change the type of parameters • Change the number of parameters • Change the order of parameters Example- Think of a login system: Login using username + password Login using mobile + password Both are login actions, right? So instead of writing different method names, we just overload: login(String username, String password) login(long mobile, String password) Same method name → different ways to use it -Another relatable one Payment systems 👇 COD UPI Card Net Banking Instead of: paymentByUPI(), paymentByCard()… We can just do: payment() payment(String upi) payment(long card) payment(String user, String pass) - Important things I learned • Just changing return type won’t work (it gives error) • Overloading happens at compile time • Works with static, private, and even final methods • Yes, even main() can be overloaded (but JVM only runs the standard one) #Java #LearningInPublic #100DaysOfCode #Programming #OOP #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 7/45 – Working with Strings in Java On Day 7 of my Java learning journey, I explored the concept of Strings, which are used to store and manipulate text data in programs. Strings are widely used in almost every application, from user input to data processing. 📚 What I Learned Today Today I learned: ✔ What strings are and how they are created in Java ✔ Important string methods like length(), charAt(), and toUpperCase() ✔ How to compare strings using equals() ✔ Understanding case-sensitive and case-insensitive comparisons 💻 Practice Work To strengthen my understanding, I implemented: • A program to reverse a string • A program to count characters in a string • A palindrome checker using string logic 🎯 Key Takeaway Strings are a fundamental part of programming, and mastering string manipulation is essential for solving real-world problems. Consistent daily practice is helping me build strong fundamentals step by step. #Java #Programming #LearningInPublic #CodingJourney #SoftwareDevelopment #Consistency
To view or add a comment, sign in
-
📚 Today’s Learning: String Concatenation & "concat()" Method in Java In today’s class, I explored an important concept in Java called String Concatenation and the "concat()" method. 🔹 String Concatenation String concatenation is the process of combining two or more strings into a single string. In Java, this is commonly done using the "+" operator. It helps developers create meaningful text outputs by joining variables and messages together. 🔹 "concat()" Method Java also provides the "concat()" method, which is a built-in method of the String class. This method is used to append one string to another string, producing a new combined string. 🔹 Important Concept – String Immutability One key concept behind these operations is that Strings in Java are immutable. This means the original string cannot be changed; instead, a new string object is created when concatenation happens. 💡 Key Takeaway: - "+" is an operator used for concatenation - "concat()" is a method of the String class used to join strings Learning these fundamental concepts strengthens my Java programming foundation and helps me understand how strings work internally. #Java #Programming #LearningJourney #StudentDeveloper #Coding TapAcademy
To view or add a comment, sign in
-
-
📘 Understanding Java MathContext Class The java.math.MathContext class in Java is used to define precision and rounding rules for numerical operations, especially when working with the BigDecimal class. It helps control how numbers are calculated and rounded in high-precision arithmetic. 🔹 Key Features • Defines precision (number of digits used in calculations) • Specifies rounding behavior using RoundingMode • Helps maintain accuracy in financial and scientific calculations 🔹 Common MathContext Fields ✔ DECIMAL32 – 7 digits precision ✔ DECIMAL64 – 16 digits precision ✔ DECIMAL128 – 34 digits precision ✔ UNLIMITED – Unlimited precision operations 🔹 Useful Methods • getPrecision() – Returns precision value • getRoundingMode() – Returns rounding mode • equals() – Compares MathContext objects • hashCode() – Returns hash code • toString() – Returns string representation 💡 Using MathContext ensures consistent and predictable results when performing precise mathematical calculations in Java. #Java #JavaProgramming #BigDecimal #MathContext #JavaDeveloper #Programming #Coding #SoftwareDevelopment #TechLearning #JavaTips
To view or add a comment, sign in
-
🚀 Day 21 of My Java Learning Journey Today, I explored String operations in Java and learned how to compare and combine strings effectively. 🔹 String Comparison Methods - "equals()" → Checks exact match (case-sensitive) - "equalsIgnoreCase()" → Ignores case differences - "compareTo()" → Compares lexicographically - Returns "0" → Strings are equal - Positive → First string is greater - Negative → First string is smaller 🔹 Concatenation Techniques - Using "+" operator String s1 = "Hello"; String s2 = "World"; System.out.println(s1 + " " + s2); - Using "concat()" method System.out.println(s1.concat(" ").concat(s2)); 🔹 Key Insight Strings are objects in Java, and all operations are performed using methods from the String class. 💡 Learning these basics helps build a strong foundation for advanced Java concepts. #Java #LearningJourney #Programming #Coding #Students #TechSkills
To view or add a comment, sign in
-
-
Day 29 of Learning Java 🚀 Today I went deeper into understanding how Java actually runs behind the scenes inside the JVM. Some interesting things I discovered today: ⚡ Learned the execution order in Java when a program has static variables → static blocks → instance variables → instance blocks → constructors → methods. ⚡ The JVM usually checks static members first. If there are no static members, execution starts from main() since it is also a static method. ⚡ Understood the use of static variables and how they save memory by storing values in a shared memory area (static segment / class area). ⚡ Learned that objects are also called instances. ⚡ Important concept: Instance variables cannot be accessed directly by static methods Static variables can be accessed by instance methods ⚡ Learned how static blocks can initialize static variables. ⚡ Explored JVM components like Class Loader, Interpreter, and JIT compiler. ⚡ Practiced compiling and running Java programs using Command Prompt (javac and java). ⚡ Also understood that the number of bytecode (.class) files generated depends on how many classes exist in the program. Small steps every day, but building strong Core Java fundamentals. 💻 #Day29 #Java #CoreJava #JVM #Programming #LearningJourney Harshit T
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
-
While learning core Java concepts, I recently explored the Collection Hierarchy, and it gave me a clearer understanding of how Java manages and organizes groups of objects efficiently. The Java Collection Framework provides a set of interfaces and classes designed to store, retrieve, and manipulate data in different ways depending on the requirement. 🔹 List – Maintains insertion order and allows duplicate elements. Examples: ArrayList, LinkedList, Vector, Stack. 🔹 Set – Stores only unique elements and prevents duplication. Examples: HashSet, LinkedHashSet, TreeSet. 🔹 Queue – Designed for processing elements typically in FIFO (First In First Out) order. Examples: PriorityQueue, ArrayDeque. Understanding this hierarchy helps developers choose the right data structure based on ordering, uniqueness, and performance requirements. #Java #JavaCollections #SoftwareDevelopment #JavaDeveloper #Programming #Learning
To view or add a comment, sign in
-
-
🚀 Understanding Liskov Substitution Principle (LSP) with a Simple Java Example One of the most misunderstood SOLID principles is the Liskov Substitution Principle (LSP). 📌 Definition: Subclasses should be replaceable for their base class without altering the correctness of the program. 💻 Example: class Notification { public void sendnot(){ System.out.println("Welcome to the takeUforward"); } } class TextNot extends Notification { public void sendnot() { System.out.println("Welcome to the takeUforward java course"); } } class WhatsAppNot extends Notification { public void sendnot() { System.out.println("Welcome to the takeUforward DSA course"); } } public class TufNot { public static void main(String[] args) { Notification nt = new TextNot(); nt.sendnot(); } } ✅ Why this follows LSP: TextNot and WhatsAppNot can fully replace Notification No unexpected behavior is introduced The program works correctly regardless of which subclass is used ❌ When LSP is violated: If a subclass breaks expected behavior, like: class SilentNotification extends Notification { public void sendnot() { throw new UnsupportedOperationException(); } } Now substituting this class breaks the system 🚨 🧠 Key Insight: Inheritance is not just about reusing code — it's about preserving behavior. 🔥 Takeaway: Always design subclasses so that they extend behavior, not break it. #Java #OOP #SOLID #LSP #SystemDesign #Programming Raj Vikramaditya i understand topic
To view or add a comment, sign in
-
-
🚀 Day – Java Learning Update ⏳ 🎯 Understanding Switch Case in Java Today, I learned about the Switch Case statement in Java, which is used to execute different blocks of code based on the value of a variable or expression. It is mainly used when we have multiple conditions to check for a single variable, making the code more readable compared to many if-else statements. 🔹 What is Switch Case? The switch statement allows a variable to be tested against multiple possible values called cases. ✔ Each case represents a possible value ✔ break stops execution after a case runs ✔ default runs if no case matches 🔹 Syntax of Switch Case switch(expression) { case value1: // code block break; case value2: // code block break; case value3: // code block break; default: // default code block } 🧑💻 Task Practiced: Traffic Signal Program I implemented a simple program using switch case to represent a traffic signal. #Java #CoreJava #JavaFullStack #SwitchCase #Programming #SoftwareDeveloper #LearningJourney 10000 Coders Meghana M
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