💻 Today’s Java Learning Update – Variables in Java In today’s Java class, we learned about Variables, which are used to store data that can be used and modified during program execution. 🔹 What is a Variable? A variable is a named memory location used to store a value. Syntax: dataType variableName = value; Example: int age = 20; --- 🔹 Types of Variables in Java 1️⃣ Local Variable Declared inside a method or block Accessible only within that method Must be initialized before use void show() { int x = 10; } --- 2️⃣ Instance Variable Declared inside a class but outside methods Each object has its own copy Stored in heap memory class Student { int marks; } --- 3️⃣ Static Variable Declared using the static keyword Shared among all objects of the class Memory allocated only once class College { static String name = "CUJ"; } --- 🔹 Rules for Naming Variables Must start with a letter, _ or $ Cannot start with a number No spaces allowed Cannot use Java keywords Follow camelCase naming convention ✅ totalMarks ❌ total marks, int --- 🔹 Why Variables Are Important? Store and manage data efficiently Make programs dynamic and flexible Improve code readability and reusability. #Java #JavaBasics #VariablesInJava #Programming #LearningJourney #CodingLife Meghana M 10000 Coders
Java Variables: Types, Syntax, and Best Practices
More Relevant Posts
-
🚀Day 4(Part 3) | core java learning journey ☕ 📘 Topic: Operators in Java Today I learned about Operators in Java, which are used to perform different types of operations on variables and values. Operators play a very important role in writing logic, conditions, and calculations in Java programs. 🔹 1. Unary Operators Unary operators work on a single operand. Examples: +, -, ++, --, ! They are mainly used to increment, decrement, or negate values. 🔹 2. Arithmetic Operators Used to perform mathematical calculations. Examples: +, -, *, /, % These operators are commonly used for addition, subtraction, multiplication, division, and modulus operations. 🔹 3. Relational Operators Used to compare two values and return a boolean result (true or false). Examples: ==, !=, >, <, >=, <= They are mostly used in decision-making statements like if and while. 🔹 4. Logical Operators Used to combine multiple conditions. Examples: && (AND), || (OR), ! (NOT) These operators are very helpful in complex conditional expressions. 🔹 5. Bitwise Operators Operate on bits and perform bit-by-bit operations. Examples: &, |, ^, ~ They are mainly used in low-level programming and performance optimization. 🔹 6. Assignment Operators Used to assign values to variables. Examples: =, +=, -=, *=, /= They help in updating variable values efficiently. 🔹 7. Shift Operators Used to shift bits to the left or right. Examples: <<, >>, >>> These operators are useful for fast calculations and bit manipulation. 🔹 8. Ternary Operator A shorthand way to write conditional statements. 🙏 Grateful to my mentor: Vaibhav Barde Sir for continuous guidance and support. #CoreJava #JavaOperators #JavaLearning #ProgrammingBasics #CodingJourney #FortuneCloud
To view or add a comment, sign in
-
-
📘 Today’s Learning – Java OOPS (Abstraction) Abstraction: Abstraction in Java is a mechanism for hiding implementation details and exposing only the necessary information to the user. It focuses on “what to do” instead of “how to do.” 🔹 Key Points: ✅ Abstract Class Cannot be instantiated (no object creation) Declared using the abstract keyword Can contain: Abstract methods (no body) Concrete (regular) methods Supports inheritance (can inherit and be inherited) ✅ Abstract Method Contains only method signature Must be overridden in the subclass If a class has at least one abstract method → it must be declared abstract ✅ Abstract Keyword Non-access modifier Used only for classes and methods 🔹 Final Keyword in Java final can be used with: 🔸 Variable → Value cannot be changed 🔸 Method → Cannot be overridden 🔸 Class → Cannot be extended ❗ Important: abstract and final cannot be used together Because abstract methods must be overridden, while final methods cannot be overridden. 🎯 Why Abstraction? ✔ Reduces complexity ✔ Improves maintainability ✔ Enhances security ✔ Supports loose coupling #Java #OOPS #Abstraction #Programming #LearningJourney #SoftwareDevelopment #Coding #JavaDeveloper Bibek Singh
To view or add a comment, sign in
-
-
Day 11 at Tap Academy: Arrays in Java Arrays in Java are a collection of homogeneous data elements of the same data type, stored in contiguous memory locations. They are objects, allocated memory in the heap, and have default values. Arrays can be classified based on dimensionality into one-dimensional, two-dimensional, and three-dimensional arrays. A one-dimensional array has a single row, while a two-dimensional array consists of rows and columns. A three-dimensional array comprises blocks, rows, and columns. The syntax for declaring arrays varies accordingly: `int[] a = new int[n];` for one-dimensional, `int[][] a = new int[m][n];` for two-dimensional, and `int[][][] a = new int[b][m][n];` for three-dimensional arrays. To access elements, use indices: `a[2] = 20;` adds an element, and `System.out.println(a[2]);` fetches it. Looping through arrays involves using for loops - one loop for one-dimensional, two loops for two-dimensional, and three loops for three-dimensional arrays. Arrays can hold homogeneous data (same data type) or be regular/jagged. Understanding array types and syntax is crucial for effective Java programming, enabling efficient data storage and manipulation.
To view or add a comment, sign in
-
-
🚀 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
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 6 | Core Java Learning Journey 📘 Topic: Looping Statements in Java Continuing my Core Java learning journey, today I explored loops in Java, which are used to execute a block of code repeatedly based on a given condition. Loops help reduce code redundancy and make programs more efficient and readable. 🔑 Concepts Explored Today: 🔹 for Loop Used when the number of iterations is known in advance. It is commonly used for counter-controlled loops. Syntax: for(initialization; condition; update) { // code to be executed } 🔹 while Loop Used when the number of iterations is not fixed. The condition is checked before executing the loop body. Syntax: while(condition) { // code to be executed } 🔹 do–while Loop Similar to the while loop, but the loop body executes at least once because the condition is checked after execution. Syntax: do { // code to be executed } while(condition); 📌 Why this matters: Loops are a fundamental part of programming and are essential for tasks like iteration, data processing, and automation. Understanding loops is crucial for writing efficient logic, working with arrays and collections, and building real-world Java applications. Special thanks to my mentor Vaibhav Barde Sir, for his guidance and clear explanation of Java loops, which made these concepts easy to understand. Step by step, strengthening my Core Java foundation and learning how to write cleaner and more optimized code. 💻🚀 #Java #CoreJava #Loops #ForLoop #WhileLoop #DoWhileLoop #ProgrammingFundamentals #JavaBasics #LearningJourney #BackendDevelopment #DailyLearning
To view or add a comment, sign in
-
-
🚀 Learning Update: Core Java — String Methods & Comparison Concepts Today’s session helped me strengthen my understanding of Java Strings, especially how different comparison techniques and inbuilt methods work internally. 📌 Key Learnings: ✅ Understood the difference between • equals() → compares values (returns boolean) • equalsIgnoreCase() → compares ignoring case • compareTo() → compares character by character and returns an integer (positive, negative, or zero) ✅ Learned how compareTo() works internally using Unicode values and how it helps determine which string is greater or smaller — very useful for sorting logic. ✅ Explored important String inbuilt methods: • length() — returns number of characters • charAt() — fetches character using index • toLowerCase() & toUpperCase() — case conversion • indexOf() & lastIndexOf() — finding character positions • substring() — extracting part of a string • split() — converting string into array • startsWith() & endsWith() — checking patterns • toCharArray() — converting string into character array ✅ Gained clarity on String immutability — understanding that operations like concat() or case conversion create new objects instead of modifying the original string. 💡 Important Insight: In interviews, knowing only definitions is not enough — explaining concepts deeply with logic and examples makes a real difference. Consistent practice and strong fundamentals are the key to becoming a confident developer. #Java #CoreJava #Programming #CodingJourney #LearningUpdate #SoftwareDevelopment #JavaStrings TAP Academy
To view or add a comment, sign in
-
-
🚀 Day 7 | Core Java Learning Journey 📌 Topic: Arrays in Java Today, I learned about Arrays in Core Java, one of the most important data structures used to store multiple values efficiently using a single variable. 🔹 What is an Array? An array is a data structure that stores multiple values of the same data type in contiguous memory locations, allowing fast access using index values. 🔹 Advantages of Arrays ✅ Helps in code optimization by reducing multiple variable declarations ✅ Provides fast data access using index ✅ Improves performance due to contiguous memory allocation ✅ Useful for handling large amounts of similar data 🔹 Disadvantages of Arrays ❌ Fixed size (cannot be resized dynamically) ❌ Memory wastage if allocated size is not fully utilized ❌ Stores only homogeneous data ❌ Insertion and deletion operations are costly 🔹 Types of Arrays in Java 1️⃣ One-Dimensional Array Used to store elements in a linear form. Syntax : int a[ ] = new int[size]; 2️⃣ Two-Dimensional Array Stores data in rows and columns (matrix form). Syntax: int a[ ][ ] = new int[rows][columns]; 3️⃣ 3D Array Used to store data in three dimensions, useful for complex data representation. Syntax : int a[ ][ ][ ] = new int[x][y][z]; 4️⃣ Jagged Array An array of arrays where each row can have a different size. Syntax : int a[ ][ ] = new int[rows][ ]; 📌 Key Learning: Arrays help in writing cleaner, optimized, and efficient code and form the foundation of advanced data structures. A special thanks to Vaibhav Barde Sir for his clear explanations and consistent support throughout the learning process. Looking forward to learning more Core Java concepts ahead! 💻✨ #CoreJava #JavaDeveloper #BackendEngineering #SoftwareDeveloper #ComputerScienceGraduate #ProgrammingLife #TechLearning #JavaConcepts
To view or add a comment, sign in
-
-
🚀 Java Learning Series — Day 10/100 📘 Relational & Logical Operators in Java Today I learned about Relational and Logical operators, which are essential for comparison, validation, and decision-making in Java applications. 🔹 Relational Operators Used to compare values and return a boolean result. == → Checks whether two values are equal != → Checks whether two values are different > → Verifies if the left value is greater than the right < → Verifies if the left value is smaller than the right >= → Checks if a value meets or exceeds a limit <= → Checks if a value is within an allowed range 🔹 Logical Operators Used to combine multiple conditions. && (AND) → True only when all conditions are true || (OR) → True when at least one condition is true ! (NOT) → Reverses the result of a condition 🔐 Real-Time Example: Login Validation 💡 Idea Behind the Example This program simulates a real-world login system where access is granted only when: Username matches Password matches User age is 18 or above Relational operators are used to compare values, while logical operators combine all login rules into a single boolean expression. The final result is stored in a boolean variable, which determines whether the login is successful or failed — without using conditional statements. 📸 (Code image attached below) ✨ Key Takeaways Relational operators handle value comparison Logical operators connect multiple validation rules Boolean expressions can decide outcomes efficiently Widely used in authentication and form validation systems 📌 Day 10 completed successfully! #Java #CoreJava #JavaDeveloper #BackendDevelopment #BackendDeveloper #SoftwareDevelopment #Programming #Coding #CleanCode #Authentication #SystemDesignBasics #ProblemSolving #DeveloperJourney #LearningInPublic #100DaysOfJava # Meghana M # 10000 Coders
To view or add a comment, sign in
-
-
🚀 Learning Update: Java — Method Overloading, Type Promotion, CLI Args & Encapsulation (OOP) In today’s live Java session, I revised some core concepts that are frequently tested in interviews and also form the foundation for Object-Oriented Programming. ✅ Key Learnings: 🔹 Method Overloading (Compiler-based / Compile-time Polymorphism) Multiple methods with the same name in the same class Java Compiler checks in order: Method Name Number of Parameters Type of Parameters If all 3 are the same → Duplicate method error If exact match isn’t found → Java tries Type Promotion (closest match) If more than one method becomes eligible after promotion → Ambiguity error 🔹 Can we overload main()? ✅ Yes, main method can be overloaded But JVM always starts execution from: public static void main(String[] args) Other overloaded main() methods can be called manually using an object/reference. 🔹 Command Line Arguments (CLI) Inputs passed in terminal get stored in String[] args Args are always Strings (even numbers) + with args performs concatenation, not addition (unless you convert manually) 🔹 OOP Introduction + Encapsulation (1st Pillar) Encapsulation = Protecting the most important data + giving controlled access Use private variables for security Provide controlled access using: ✅ Setter → set/update data (usually void) ✅ Getter → get/return data (has return type) Add validations inside setter (ex: prevent negative bank balance) 📌 Realization: These concepts are not just theory — they directly relate to writing secure, industry-ready code. #Java #OOP #Encapsulation #MethodOverloading #CommandLineArguments #LearningUpdate #FullStackDevelopment #PlacementPreparation #TapAcademy #SoftwareDevelopment TAP Academy
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