#32 Array of Objects in Java

  Рет қаралды 157,251

Telusko

Telusko

Күн бұрын

Check out our courses:
Enterprise Java Spring Microservices: go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : bit.ly/java-sp...
Coupon: TELUSKO20 (20% Discount)
Udemy Courses:
Java:- bit.ly/JavaUde...
Spring:- bit.ly/SpringU...
Java For Programmers:- bit.ly/javaPro...
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusk...
In this lecture we are discussing about array of objects:
-- If we create array by default value assign for each type of array
-- The new operator automatically initializes the elements of an array to their default value, which, for example, is zero for all numeric types
and null for all reference types.
-- why we should we know length of array using length property?
-- There is array out of bound exception.
How to create array of object and what does it means?
-- just like to create array for int, float, char we can create array of object
-- when we we create array of object it means we create an array which can hold the reference of object.
e.g
class Student{
}
Student st=new Student();
we know st is reference and new Student() is object.
and st hold reference of student object.
similarly whenever we create array of object
Student sts[]=new Student[5];
it means we can create an array of Student reference type which can hold 5 different reference of
Student object.
sts[0]=new Student();
sts[1]=new Student();
sts[2]=new Student();
sts[3]=new Student();
sts[4]=new Student();
Github repo : github.com/nav...
Java:- bit.ly/JavaUde...
Spring:- bit.ly/SpringU...
More Learning :
Java :- bit.ly/3x6rr0N
Python :- bit.ly/3GRc7JX
Django :- bit.ly/3MmoJK6
JavaScript :- bit.ly/3tiAlHo
Node JS :- bit.ly/3GT4liq
Rest Api :-bit.ly/3MjhZwt
Servlet :- bit.ly/3Q7eA7k
Spring Framework :- bit.ly/3xi7buh
Design Patterns in Java :- bit.ly/3MocXiq
Docker :- bit.ly/3xjWzLA
Blockchain Tutorial :- bit.ly/3NSbOkc
Corda Tutorial:- bit.ly/3thbUKa
Hyperledger Fabric :- bit.ly/38RZCRB
NoSQL Tutorial :- bit.ly/3aJpRuc
Mysql Tutorial :- bit.ly/3thpr4L
Data Structures using Java :- bit.ly/3MuJa7S
Git Tutorial :- bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
www.telusko.com

Пікірлер: 34
@sirfmgamer5655
@sirfmgamer5655 3 ай бұрын
you sir have just got another subscriber. beautiful explanation and I wrote so many lines of code until you showed how to simply used those three attributes for ALL of the student objects instead of making one attribute for each object. definitely i am going to check out all of your other videos too. thank you.
@elikmtl
@elikmtl Жыл бұрын
The best explanation of Array of Objects in Thank you!🙏
@tejaswinigm2606
@tejaswinigm2606 Жыл бұрын
I have a list which I got from DB query based on few conditions, which contains below location details... I want o/p as segregated locations i.e all cities and zipcodes into its state, all states into country Cou1 state1 city1 zip1 Cou1 state2 city2 zip2 Cou1 state1 city 3 zip3 O/p sld be as Cou1 State1 Cit1 - zip1 Cit3 - zip3 State2 Cit2 - zip2
@AbdulAhad-uj1nf
@AbdulAhad-uj1nf Жыл бұрын
First comment from #SriLanka.Thanks you so much for your help
@jooyeonsimp
@jooyeonsimp 4 ай бұрын
So array is going to store objects values in place of objects ?? Basically in a array each element consists of 3 different student values
@HariPrasad-qe3hd
@HariPrasad-qe3hd Жыл бұрын
More precise way for(Student s: students) { System.out.println(s.name + ":" + s.mark); }
@JehanSaren
@JehanSaren Жыл бұрын
Nice sir, can you do this using with constructor?
@owl166
@owl166 10 ай бұрын
Can we use collection framework to create an array of objects.....?? Thanks in advance
@aninditadas7348
@aninditadas7348 Жыл бұрын
Hello Sir, Getting below error error: cannot find symbol Student s1=new Student(); ^ symbol: class Student location: class ArrayObject ArrayObject.java:4: error: cannot find symbol Student s1=new Student(); ^ symbol: class Student location: class ArrayObject 2 errors MY code class ArrayObject{ public static void main(String a[]){ Student s1=new Student(); } }
@aninditadas7348
@aninditadas7348 Жыл бұрын
I got it solved, by creating a class using Student. Below is the code class Student{ String name=""; int age= 0; }
@simikhuzwayo
@simikhuzwayo 5 ай бұрын
3:40 Good explanation
@ankitbaranwal883
@ankitbaranwal883 Жыл бұрын
What is the difference b/w array of objects and collection functionality wise
@singirikumar2782
@singirikumar2782 11 ай бұрын
Collection functionality wise ... If u create a object as collections U can access lot of methods to perform CRUD operations on data Which is in collection..nd also growable in nature size wise nd it follows some data Structures...i.e data in some order ..ascending or descending but if u create object as array ...it is fixed u cannot add new data and u cannot delete and allows it won't follow data structures When ever u r requirement is fixed heterogenous data and no need of delete of data .. we will go for Object array ..
@pankajSingh-nh2qi
@pankajSingh-nh2qi Жыл бұрын
public static void main(String[] args) use this if showing error
@actandrepeat
@actandrepeat Жыл бұрын
Is the length property a static attribute of the array object?
@kazialhasan5433
@kazialhasan5433 Жыл бұрын
Getting error when Student class is not Static. But Navin didn't have it as static. What am I doing wrong?
@RaviYash-fs2gh
@RaviYash-fs2gh 10 ай бұрын
I have two doubts here, 1.When we create an object the class name should be same 2. When we create the three student objects you didnt intialize the data types for rollno, name, marks. If anyone knows please rectify my doubts. Thanks in advance
@SPragnasya
@SPragnasya 9 ай бұрын
Okay let me address your doubts: 1. Yes, when you create an object in Java, the class name should be the same. For example: Imagine you have a class called Student. If you want to make an actual student object, you say Student st = new Student();. This naming consistency helps others (and yourself) easily understand what type of object is being created. class Student { // Class definition } Student st = new Student(); // Creating an object of the Student class 2. Coming to your second doubt, consider the below example : class Student { int rollNo; String name; double marks; } public class Main { public static void main(String[] args) { Student st1 = new Student(); st1.rollNo = 1; st1.name = "John"; st1.marks = 90.5; Student st2 = new Student(); st2.rollNo = 2; st2.name = "Jane"; st2.marks = 85.0; } } In the Student class, you have defined three instance variables: int is the data type for rollNo, String for name, and double for marks. These are the data types for the respective fields. In the Main class, you are creating two instances of the Student class (st1, st2) and initializing the data for each object. Hope you understood 😊!
@pierreoosthuizen9444
@pierreoosthuizen9444 Жыл бұрын
What EDI do you use?
@dhruvinbhatt6414
@dhruvinbhatt6414 Жыл бұрын
I think it's VS CODE
@informationtechtips5391
@informationtechtips5391 Жыл бұрын
Vs code
@royalgaming3132
@royalgaming3132 Жыл бұрын
VS Code (Visual studio code)
@Rahul-d7q3r
@Rahul-d7q3r Жыл бұрын
EDI or IDE 😂
@Jake-cb8dm
@Jake-cb8dm Жыл бұрын
@@Rahul-d7q3rman I thought I was losing my mind thinking the community changed the name
@kvelez
@kvelez Жыл бұрын
public class Main{ public static void main(String[] args) { Student stud = new Student(); stud.roll = 1; stud.marks = 88; stud.name = "Kevin"; Student stud2 = new Student(); stud2.roll = 2; stud2.marks = 78; stud2.name = "Marco"; Student stud3 = new Student(); stud3.roll = 3; stud3.marks = 90; stud3.name = "Justin"; Student[] students = new Student[3];//Array with references students[0] = stud;//Manual objects students[1] = stud2; students[2] = stud3; for (Student student : students) { System.out.print(student.name + " " + student.roll + " " + student.marks + " "); } } } class Student { int roll; int marks; String name; }
@faltuCoder35
@faltuCoder35 Жыл бұрын
seson 2 kha hai bhae
@0shaad
@0shaad Жыл бұрын
How without proper {} this code is working, You open { in last class and in main method but didn't close it
@niksyt8666
@niksyt8666 Жыл бұрын
i got an error
@puruagni1927
@puruagni1927 6 ай бұрын
Why are you not updating VS Code? Please update VS Code.
@LokendraArya21
@LokendraArya21 Ай бұрын
It's sir choice 😅
@YokutjonTohirova-mu5gk
@YokutjonTohirova-mu5gk 2 ай бұрын
🔥🔥🔥🔥
@jitendratiwari4292
@jitendratiwari4292 Жыл бұрын
In hindi?
@sneha-yp2ew
@sneha-yp2ew Жыл бұрын
Is Kiran is your best friend???😁
#33 Enhanced for Loop in Java
5:27
Telusko
Рет қаралды 105 М.
Valid Anagram - Leetcode 242 - Python
4:14
Tim Huang
Рет қаралды 4
Random Emoji Beatbox Challenge #beatbox #tiktok
00:47
BeatboxJCOP
Рет қаралды 65 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 30 МЛН
#34 What is String in Java
7:24
Telusko
Рет қаралды 148 М.
Java array of objects 🍱
6:16
Bro Code
Рет қаралды 114 М.
#37 Static Variable in Java
7:06
Telusko
Рет қаралды 170 М.
#53 Packages in Java
12:20
Telusko
Рет қаралды 220 М.
Learn JavaScript OBJECTS in 7 minutes! 🧍
7:01
Bro Code
Рет қаралды 70 М.
#28 Creation of Array in Java
7:29
Telusko
Рет қаралды 176 М.
Primitive Types and Reference Types in Java
6:28
Neso Academy
Рет қаралды 141 М.
Array vs. ArrayList in Java Tutorial - What's The Difference?
17:36
Coding with John
Рет қаралды 549 М.
#40 Encapsulation in Java
11:42
Telusko
Рет қаралды 198 М.
Random Emoji Beatbox Challenge #beatbox #tiktok
00:47
BeatboxJCOP
Рет қаралды 65 МЛН