+ 3
Can i create more than one object with same name for a class. For example , like the program in my link
8 Answers
+ 2
not sure what you mean but you can never create two variables/objects with the same name. (except in different scopes)
+ 1
why dont you just click run and see for yourself?
+ 1
now where are you using the same name?
+ 1
@Jeremy. Sorry š
. I forgot about the Scope of objects. and I was thinking that the objects with same name are used there . Actually. there in the push operation each time when it is getting called. object is getting created and getting destroyed.
+ 1
@Rudolph flash. If they get destroyed then how can we access them again during push ?
0
@ Jeremy. I've tested it š
it has shown me error ,but why still I asked this is. In java for stacks using linked lists objects with same name are created for every push operation then why isn't than an error ?
0
@ Rudolph flash. In java for stacks using linked lists objects with same name are created for every push operation then why isn't that an error ? I have seen the code for stacks from Google. I didn't try it.But is it the same thing ?that in stack objects of Same name are getting created.
0
@Rudolph Flash. Can you please this code ?
public class LinkList
{
private Node first = null;
public void push(int data)
{
Node n = new Node(data);
n.next = first;
first = n;
}
}
public class LinkListStackDemo
{
public static void main(String[] args)
{
LinkList st = new LinkListStack();
st.push(50);
st.push(70);
st.push(190);
}
}