قناة هندسة الحاسب
836 subscribers
2.29K photos
38 videos
969 files
321 links
1. القناة مخصصة للدراسة ولمقررات القسم وأخباره، يمنع نشر غير ما يتعلق بهذا إلا في حالات استثنائية.

2. يجب استعمال الهاشتاقات لكل مقرر يراد نشر شيء يخصه، وهاشتاق #إعلان للإعلانات.
Download Telegram
#EC252
[Lecture 5]

the toString() method and how it's used

https://www.javatpoint.com/understanding-toString()-method
#EC252
ملخص سلايد الدكتور
[Lecture 5]

• an object is always created from its class by calling the method (the constructor) that creates the object with the command new

• a class has to define what methods and attributes the objects created from the class will have

• defining attributes within an object is done in quite a familiar fashion as normal variable

• writing the keyword private before attributes makes them hidden within the object and not show outside of it

• hiding things within an object is called encapsulation

• variables defined within a class are called object variables, object fields or object attributes.

• the 'state' of the object is determined by the values that have been set to its variables

• self-defined objects are created in the same way as ready-made objects, with the new command

•  a constructor is a method used to instantiate and initialize objects
•  it must have the same name as the class
•  does not have a return type
•  is invoked using the new operator

• if you don't create a constructor for your class, java will automatically create a default constructor
• a default constructor is a zero-argument constructor (takes no parameters), with an empty body, and can only be used to create objects from the class

• toString() : is a method that returns a string representation
• the System.out.println method requests the string representation of an object and then prints it, so..

System.out.println( objectName );
// same output as
System.out.println( objectName.toString );

• the "this" keyword
is a refrence to the object itself (another name for the object)
It's used before the dot operator "." to:
- reference instance data fields
- reference instance methods
- invoke a constructor

• String.format("%.2f, value);
returns a string where the value is rounded to contain 2 decimals

• when calling an object's method within the object, you can ditch the "this" keyword


• Random: is a ready-made class in java you can use to create objects that has the following methods:

.nextInt();
can be given an integer value as a parameter
returns a random integer within the range [0, parameter-1]

.nextDouble();
doesn't accept any parameters
returns the next pseudorandom, "uniformly" distributed double value between 0.0 and 1.0 from this random number generator's sequence

.nextGaussian();
doesn't accept any parameters
returns the next pseudorandom, Gaussian "normally" distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence
8
#Ec201
محاضرة اليوم.
ملاحظة 💡
لاتوجد توتوريـَال
Java naming conventions:
Class names: Capitalize the first letter in each name (Pascal).

Variables and method names: Lowercase the first word, capitalize the first letter in all subsequent words (camelCase).

Constants: Capitalize all letters.
#EC252
4
مرة مرة بنبعت اسئلة mcq
#EC252
1
A call to a method with a void return type is always a statement itself, but a call to a value-returning method cannot be a statement by itself.
Anonymous Quiz
38%
True
62%
False
1
#ec310 ep13
3
MidtermAnswers (1).pdf
332.9 KB
#EC252 midterm
من نفس المكان الي جاب منه الفاينل سيمسترات فاتوا
3