Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,323 members, 7,811,953 topics. Date: Monday, 29 April 2024 at 01:25 AM

What The Different Between ENUM And ARRAY In Java - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / What The Different Between ENUM And ARRAY In Java (3722 Views)

Java Array Problem / Can An Array In Java Hold Multiple Types? / Community Service | I Am To Teach Everything I Know In Java For Free! (2) (3) (4)

(1) (2) (Reply) (Go Down)

Re: What The Different Between ENUM And ARRAY In Java by seunthomas: 12:49am On Oct 04, 2016
Please ohh. Java guru's based on this code, can an array of objects hold any type or just a single type:


class Test{



public static void main(String args[]){
boolean status=true;
char c='Y';
int v=100;
Object s[]=new Object[3];
s[0]=status;
s[1]=c;
s[2]=v;

System.out.println(s[0]);
System.out.println(s[1]);
System.out.println(s[2]);

}
Re: What The Different Between ENUM And ARRAY In Java by timtoday: 12:50am On Oct 04, 2016
seunthomas:

JEEEZ.

I am tired of arguing with you.

Next time, try to know before arguing.

You are the one that don't know yet you are shouting everywhere! I know you will jump the gun!

I just caught you using your own code! I just don't write codes, I understand what I write unlike you, who believe everything is an object in Java!

I have demonstrated to you every time you raise a point that I know what is happening under the hood! Not just talk, talk...

Please next time. Read well before you answer questions.

Arrays in Java holds a fixed number of values of a single type. It can't be more clearer. Every other object which extends an Object is an Object! It is still a single type! Can that be so difficult? And it is not a primitive datatype. Which is one of the thing makes everything in Java NOT to be an Object. The other is it has static types. Awosh!!!!
Re: What The Different Between ENUM And ARRAY In Java by seunthomas: 12:53am On Oct 04, 2016
timtoday:


You are the one that don't know yet you are shouting everywhere! I know you will jump the gun!

I just caught you using your own code! I just don't write codes, I understand what I write unlike you, who believe everything is an object in Java!

I have demonstrated to you every time you raise a point that I know what is happening under the hood! Not just talk, talk...

Please next time. Read well before you answer questions.

Arrays in Java holds a fixed number of values of a single type. It can't be more clearer. Every other object which extends an Object is an Object! It is still a single type! Can that be so difficult? And it is not a primitive datatype. Which is one of the thing makes everything in Java NOT to be an Object. The other is it has static types. Awosh!!!!

Maybe we dont understand each other, what are primitive types and what is an object also what is an array??
Re: What The Different Between ENUM And ARRAY In Java by seunthomas: 12:54am On Oct 04, 2016
@timtoday I know am correct am just trying to rub it in well, so you can further show your folly.

Abi you think its beans to learn just one language for several years??
I pick up a new language in 3 days max but spent years learning Java because it was key to understanding OOP.
Re: What The Different Between ENUM And ARRAY In Java by timtoday: 1:12am On Oct 04, 2016
seunthomas:
@timtoday I know am correct am just trying to rub it in well, so you can further show your folly.

Abi you think its beans to learn just one language for several years??
I pick up a new language in 3 days max but spent years learning Java because it was key to understanding OOP.

I have told you, leave those your self praise singing to those it will catch.. Am not in that league!
If you have to pat your ego in a public forum, you problem have a low self-esteem.

I will help one more time maybe you can see clearly and more especially for those who may want to follow your wrong side of the books, which only God knows where they are from.


class Demo {

public static void main (String[] args) {

Object b = new Boolean(false); // why is this possible
System.out.println(b);
System.out.println(b.getClass());

boolean b2 = true;
// uncomments the following lines to get the errors
//System.out.println(b2); // what type is this?
//System.out.println(b2.getClass()); // can you do this?

// what about this?
Object b3 = b2;
System.out.println(b3); // what type is this now?
System.out.println(b3.getClass()); // can you do this now?
}
}


I don't need to tell you am right. My points and posts justify itself...

Just make sure you read the link on array I linked to in one of my post and stop telling yourself you know, then it is obvious you know NOTHING!
Good Morning!

1 Like

Re: What The Different Between ENUM And ARRAY In Java by seunthomas: 1:14am On Oct 04, 2016
timtoday:


I have told you, leave those your self praise singing to those it will catch.. Am not in that league!
If you have to pat your ego in a public forum, you problem have a low self-esteem.

I will help one more time maybe you can see clearly and more especially for those who may want to follow your wrong side of the books, which only God knows where they are from.


class Demo {

public static void main (String[] args) {

Object b = new Boolean(false); // why is this possible
System.out.println(b);
System.out.println(b.getClass());

boolean b2 = true;
// uncomments the following lines to get the errors
//System.out.println(b2); // what type is this?
//System.out.println(b2.getClass()); // can you do this?

// what about this?
Object b3 = b2;
System.out.println(b3); // what type is this now?
System.out.println(b3.getClass()); // can you do this now?
}
}


I don't need to tell you am right. My points and posts justify itself...

Just make sure you read the link on array I linked to in one of my post and stop telling yourself you know, then it is obvious you know NOTHING!
Good Morning!

Shaking my head right now.

You must be really young.

Cos you just want to win even when you are wrong.

I hope you wont go outside and do this.

By the way you are all wrong. Class and Objects are different.
Re: What The Different Between ENUM And ARRAY In Java by timtoday: 1:36am On Oct 04, 2016
seunthomas:


Shaking my head right now.

You must be really young.

Cos you just want to win even when you are wrong.

I hope you wont go outside and do this.

By the way you are all wrong. Class and Objects are different.

You see, you really have low self-esteem. Age has got nothing to do with showing you that. Am actually 2 yrs old, here you are struggling with a 2yr old. It is not winning an argument. That is your area of specialization.

By the way you are all wrong. Class and Objects are different.
But you should have shown me HOW naw, clearly defining what both are. But as usual, you must change the point of discussion, since it is obvious you don't know what you are talking about.

For your information, an "object" "of a class" is an instance of that class. Am sure I have made mention of that again and again. Using the word "instance"
But in your mind, one who had shown you times and again that he knows what is talking about DOES NOT KNOW THE DIFFERENCE!

Obviously you live in your own reality! That is why you will claim "Everything in Java is an OBJECT!" Remember am 2 yrs Old. Please take your own advise and probably go sleep with it.
I hope you
Methuselah
wont go outside and do this.
!
Re: What The Different Between ENUM And ARRAY In Java by seunthomas: 1:41am On Oct 04, 2016
timtoday:


You see, you really have low self-esteem. Age has got nothing to do with showing you that. Am actually 2 yrs old, here you are struggling with a 2yr old. It is not winning an argument. That is your area of specialization.

But you should have shown me HOW naw, clearly defining what both are. But as usual, you must change the point of discussion, since it is obvious you don't know what you are talking about.

For your information, an "object" "of a class" is an instance of that class. Am sure I have made mention of that again and again. Using the word "instance"
But in your mind, one who had shown you times and again that he knows what is talking about DOES NOT KNOW THE DIFFERENCE!

Obviously you live in your own reality! That is why you will claim "Everything in Java is an OBJECT!" Remember am 2 yrs Old. Please take your own advise and probably go sleep with it. Methuselah !


Ok ohh. Mr only single types can be stored in a Java Array.
Ignorance is a killer.
Re: What The Different Between ENUM And ARRAY In Java by timtoday: 1:55am On Oct 04, 2016
seunthomas:



Ok ohh. Mr only single types can be stored in a Java Array.
Ignorance is a killer.

Documentation are made for humans. Please read it. It will help you to stop making yourself a laughing stock on this thread. I pointed you to one, not to stackoverflow, but your arrogance will not allow you to go check.

Am sure you didn't know what the method getClass() returns that is why you are saying
..Class and Objects are different..
as if you are raising a revelation.

Go educate yourself properly with the tools, you claim you know. And stop showing us that you have wasted 3 yrs of your life learning nothing! Than cut and paste!

1 Like

Re: What The Different Between ENUM And ARRAY In Java by seunthomas: 8:39am On Oct 04, 2016
timtoday:


Documentation are made for humans. Please read it. It will help you to stop making yourself a laughing stock on this thread. I pointed you to one, not to stackoverflow, but your arrogance will not allow you to go check.

Am sure you didn't know what the method getClass() returns that is why you are saying as if you are raising a revelation.

Go educate yourself properly with the tools, you claim you know. And stop showing us that you have wasted 3 yrs of your life learning nothing! Than cut and paste!
See this man ohhh.

Were you dey when i dey work on my own personal implementation of the JVM in 2006??

Me i read the documentatations you are talking about, i also read language specifications as well as understand the concept behind stuff very well.


Anyway, like i said ignorance is a killer.

Mr only single types can be stored in a Java Array.
Re: What The Different Between ENUM And ARRAY In Java by lekropasky(m): 5:03pm On Oct 05, 2016
seunthomas:

See this man ohhh.

Were you dey when i dey work on my own personal implementation of the JVM in 2006??

Me i read the documentatations you are talking about, i also read language specifications as well as understand the concept behind stuff very well.


Anyway, like i said ignorance is a killer.

Mr only single types can be stored in a Java Array.
Seriously, this guy doesnt know anything at all about Java, and i am not even sure you know any other language, and thats the reason why you are arguing that array can hold more than one datatype/object, a new Java programmer that is learning with mind wont even say this, talkless of your 100years experience with Java. Its a pity. I dont even know why you do this, maybe because you want to nailed down some potential clients from here. Its a pity once again.
Re: What The Different Between ENUM And ARRAY In Java by seunthomas: 5:12pm On Oct 05, 2016
lekropasky:
Seriously, this guy doesnt know anything at all about Java, and i am not even sure you know any other language, and thats the reason why you are arguing that array can hold more than one datatype/object, a new Java programmer that is learning with mind wont even say this, talkless of your 100years experience with Java. Its a pity. I dont even know why you do this, maybe because you want to nailed down some potential clients from here. Its a pity once again.

Some people will just open their mouth to sha talk sha.

Please knowledgeable Java programmer, explain this code which is an array of objects and holds different types of object:

class Test{



public static void main(String args[]){
boolean status=true;
char c='Y';
int v=100;
Object s[]=new Object[3];
s[0]=status;
s[1]=c;
s[2]=v;

System.out.println(s[0]);
System.out.println(s[1]);
System.out.println(s[2]);

}
Re: What The Different Between ENUM And ARRAY In Java by timtoday: 7:07pm On Oct 05, 2016
seunthomas:


Some people will just open their mouth to sha talk sha.

Please knowledgeable Java programmer, explain this code which is an array of objects and holds different types of object:

class Test{



public static void main(String args[]){
boolean status=true;
char c='Y';
int v=100;
Object s[]=new Object[3];
s[0]=status;
s[1]=c;
s[2]=v;

System.out.println(s[0]);
System.out.println(s[1]);
System.out.println(s[2]);

}

@lekropasky Please don't just disturb yourself over this guy. It is obvious he knows nothing!

He was finding it difficult to understand simple concepts in Java, yet he boast of writing his own JVM in 2006! Yet he didn't know that EVERY CLASS in Java EXTENDS the "class" Object EXCEPT Object itself.. Which will make ANY instance of ANY CLASS, a TYPE of "Class" Object. Which still SHOUT to the ignorance of the Methuselah programmer that an ARRAY in Java takes only a SINGLE TYPE!

Please note, I didn't say TYPES our Methuselah programmer did!

Methuselah programmer, Sir, Why change to the statement below?
which is an array of objects and holds different types of object

But you initially said those were PRIMITIVES TYPES! So now they are different types of object? So, I have educated you now a bit, but shame will not allow you to be humble. Let me still help your arrogant ignorance a bit more.

Remove the word "different" here they are all TYPE of Object,, all you need to do to know this is, just use instanceof to do a test and you will be healed totally!
Hope you know how to use that?! Let me not take the trick here is how
if (s[0] instanceof Object) System.out.println("It is an Object!"wink;


Lastly, I dare you @seunthomas To quote the very first sentence of this Oracle Java Tutorial https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html and prove me wrong!

But if you will not, please don't reply me! I know you will and further show how empty you are on Java! Selah!
Re: What The Different Between ENUM And ARRAY In Java by lekropasky(m): 7:35pm On Oct 05, 2016
seunthomas:


Some people will just open their mouth to sha talk sha.

Please knowledgeable Java programmer, explain this code which is an array of objects and holds different types of object:

class Test{



public static void main(String args[]){
boolean status=true;
char c='Y';
int v=100;
Object s[]=new Object[3];
s[0]=status;
s[1]=c;
s[2]=v;

System.out.println(s[0]);
System.out.println(s[1]);
System.out.println(s[2]);

}
this code will never run. YES. Because, boolean, char, int are primitive types not object, if you had written this....
Object[] s = new Object[3]
Integer number = new Integer(1);
s[0] = number; //this is correct, remember, class Integer extends Object and thats why you can store it instance inside an array of Object. Your code is rubbish, what you need to understand is that all Java classes implicitly extends an Object class which makes them an Object. You tried to assign a primitive type value to an object, its very funny, i am not even sure you know the different between 'String' and 'int'. i cant believe this is coming from somebody that tried to implement his own JVM its a SHAME. I didnt even tried this when i was a dummy in Java. Its so sad. Go and learn bro.
Re: What The Different Between ENUM And ARRAY In Java by seunthomas: 9:15pm On Oct 05, 2016
lekropasky:


class Test{



public static void main(String args[]){
boolean status=true;
char c='Y';
int v=100;
Object s[]=new Object[3];
s[0]=status;
s[1]=c;
s[2]=v;

System.out.println(s[0]);
System.out.println(s[1]);
System.out.println(s[2]);

}
}
this code will never run. YES. Because, boolean, char, int are primitive types not object, if you had written this....
Object[] s = new Object[3]
Integer number = new Integer(1);
s[0] = number; //this is correct, remember, class Integer extends Object and thats why you can store it instance inside an array of Object. Your code is rubbish, what you need to understand is that all Java classes implicitly extends an Object class which makes them an Object. You tried to assign a primitive type value to an object, its very funny, i am not even sure you know the different between 'String' and 'int'. i cant believe this is coming from somebody that tried to implement his own JVM its a SHAME. I didnt even tried this when i was a dummy in Java. Its so sad. Go and learn bro.

The code actually runs fine. If you tried it you would discover you are big f**l. Please try to run it and confirm your folly.

1 Like

(1) (2) (Reply)

Simple Algorithm Exercise / Error With XHTML Markup / Contest[closed] : Program A Function to find if a phrase. is in a string

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 56
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.