Skip to content

Commit 21573cd

Browse files
committed
Migrate development environment from Windows to macOS and continue project updates
- Shifted primary development environment from Windows to macOS to ensure better performance, stability, and streamlined workflow for Java development. - Removed OS-specific metadata and ensured platform-agnostic project compatibility. - Normalized line endings to LF for cross-platform consistency. - Verified and adjusted file paths, permissions, and encoding settings to suit macOS environment. - Cleaned up unnecessary Windows-generated files and updated Git configuration accordingly. - Future commits and development will now be managed entirely from macOS. This migration ensures a cleaner, more consistent setup moving forward and prepares the project for scalable development across Unix-based systems. Future development will continue on macOS for a smoother, Unix-based experience. Signed-off-by: Someshdiwan <[email protected]>
1 parent 29fc954 commit 21573cd

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class Attributes
2+
{
3+
private int number; //every 'Attributes' object has a number
4+
private String word; //every 'Attributes' object has a word
5+
6+
public static void main(String[] args)
7+
{
8+
//creating an object
9+
Attributes object1 = new Attributes();
10+
//assigning values to its attributes
11+
object1.number = 9;
12+
object1.word = "Grade";
13+
14+
//creating a different object with different attributes
15+
Attributes object2 = new Attributes();
16+
object2.number = 2022;
17+
object2.word = "Java";
18+
19+
//accessing values of attributes of objects
20+
System.out.println("object1 has a number " + object1.number);
21+
System.out.println("object2 has a word " + object2.word);
22+
}
23+
}

Section16StaticFinal/src/Car.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class Car
2+
{
3+
private String model;
4+
private boolean isElectric;
5+
private double price;
6+
7+
public Car(String type, boolean runsOnBatteries, double cost)
8+
{
9+
//we assigned the values passed as arguments of the constructor as instance attributes
10+
model = type;
11+
isElectric = runsOnBatteries;
12+
price = cost;
13+
}
14+
}

Section16StaticFinal/src/Note.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
References vs Objects vs Instances
2+
3+
Person p1 = new Person(); // p1 is a reference, new Person() is an object (instance)
4+
5+
you can create many objects using a single class. each may have unique attributes or values.
6+
7+
static variable(class variable):
8+
9+
Declared using static keyword.
10+
It is also know as a static members variable.
11+
Every instance of class shares static variables.
12+
so if changes are made with that static variables all other instances of that class will see the affects if that changes.
13+
14+
class Counter {
15+
static int count = 0; // shared by all instances
16+
Counter() {
17+
count++; // increases the same shared variable
18+
}
19+
}
20+
21+
static variables are used for:
22+
1.Storing counters
23+
2.Generating unique id.
24+
3.Storing a constant values that doesn't change like a pi.
25+
4.Creating and controlling access to the shared resources.
26+
27+
28+
static methods & Instances Method:
29+
30+
it is declared using a static modifier.
31+
static methods can't access directly using a instances' method.
32+
and directly also a instances variables.
33+
we can't use 'this' keyword.

0 commit comments

Comments
 (0)