A Question about JAVA

Hi

Q:

What was LOST and What was GAIEND in java with not including the pointers in C++?

will i found that java have pointers.. they're just not explicit..and don't allow Pointer Arithmetic ...

so...can u plz answer the Q..

and plz.. give me an example "in C++" that i cannot do it in java..and how to get around it "in java"..

thank you ...

[385 byte] By [al--waheeda] at [2007-11-27 6:21:52]
# 1
Both Java and C++ are Turing complete which means that anything computable is computable in both.Pointers just happen to be a tool available in C++. The trade off in simplicity and code maintainability are amongthe reasons why Java didnt provide that particular tool.
TuringPesta at 2007-7-12 17:38:37 > top of Java-index,Java Essentials,Java Programming...
# 2

> What was LOST and What was GAIEND in java with not

> including the pointers in C++?

Less complexity and more stable applications. Downside: you can't randomly write into your RAM. Upside: you can't write randomly into your RAM.

Never rebooted my PC that much than when I was still writing C.

CeciNEstPasUnProgrammeura at 2007-7-12 17:38:37 > top of Java-index,Java Essentials,Java Programming...
# 3
void pointer. Pointing to the void makes me feel like saying: "Let there be light".
Hippolytea at 2007-7-12 17:38:37 > top of Java-index,Java Essentials,Java Programming...
# 4
thanks...waiting for an example using pointers in c++ v.s pointers in java"code example"thanks again..
al--waheeda at 2007-7-12 17:38:37 > top of Java-index,Java Essentials,Java Programming...
# 5

> thanks...

>

> waiting for an example using pointers in c++ v.s

> pointers in java

> "code example"

You'll be waiting a while, dude...

Pointers do not exist in Java... they are abstracted away from us, and we do not have access to them as Java programmers, (with very few exceptions).

kevjavaa at 2007-7-12 17:38:37 > top of Java-index,Java Essentials,Java Programming...
# 6
> waiting for an example using pointers in c++ v.s> pointers in java> "code example"Waiting for you to acquire some initiative. Yawmark (<-- not holding my breath)
yawmarka at 2007-7-12 17:38:37 > top of Java-index,Java Essentials,Java Programming...
# 7

ok.. i will write a c++ code and could someone

give me how its done in java <<i dont know java ..

void LinkList :: InsertSorted( int x)

{

if ( head == 0 || head ->data >x )

InsertFirst(x);

else

{

Node *q = head;

Node *p= head->next;

while( p != 0 && p->data < x)

{

q=p;

p= p->next;

}

node *r = new Node(x);

q->next= r;

r->next = p;

}

}

al--waheeda at 2007-7-12 17:38:37 > top of Java-index,Java Essentials,Java Programming...
# 8

class LinkedList {

void insertSorted(int x) {

if (head == null || head.data > x) {

insertFirst(x);

}

else {

Node q = head;

Node p = head.next;

while (p != null && p.data < x) {

q = p;

p = p.next;

}

Node r = new Node(x);

q.next = r;

r.next = p;

}

}

}

quittea at 2007-7-12 17:38:37 > top of Java-index,Java Essentials,Java Programming...
# 9
the last example was simplewhat about thisT[] ta= new T[54];T* pT= &ta[41]; pT++; ta= null;can i do it in java ...?and howplease show me...thanks
al--waheeda at 2007-7-12 17:38:37 > top of Java-index,Java Essentials,Java Programming...
# 10
> pT++; >> can i do it in java ...?and how please show me...The question is: what exactly do you want to achieve? There's no direct conversion to the code you posted as it uses pointer arithmetics. Though, the result is achievable in Java, too.
quittea at 2007-7-12 17:38:37 > top of Java-index,Java Essentials,Java Programming...
# 11
Very true. You should be bothered about what you need to achieve rather than try to achive some language syntax in some other language.
NuSina at 2007-7-12 17:38:38 > top of Java-index,Java Essentials,Java Programming...
# 12

ok..ok

the last code have some problems..

this is the right one

int T[100];

for (int i=0; i<99; i++)

T[i]=i;

int *ta= &T[54]; // is this possible in Java ?

// if yes then write it down please;

// if no.. then is their a way to get it done ..?

int *pT= &ta[41];//the same as the last commente;

pT++;//can this be done in java ?

// if yes then write it down please;

// if no.. then is their a way to get it done ..?

ta= NULL;

i hope i find the answer...

> Very true. You should be bothered about what you need

> to achieve rather than try to achive some language

> syntax in some other language.

in my first post their was a Q ..

that Q is a part of an assignment from my

doctor in Computer Science College...

and i want to put some examples for him...

al--waheeda at 2007-7-12 17:38:38 > top of Java-index,Java Essentials,Java Programming...
# 13
> and i want to put some examples for him...You want to have other people write the examples for you? Why not just cut out the middle man (i.e., you), and have your professor come talk to us directly?~
yawmarka at 2007-7-12 17:38:38 > top of Java-index,Java Essentials,Java Programming...
# 14

> ok..ok

> the last code have some problems..

> this is the right one

>

> > int T[100];

> for (int i=0; i<99; i++)

> T[i]=i;

>

> int *ta= &T[54]; // is this possible in Java

> ?

> // if yes then write

> it down please;

> // if no.. then is

> their a way to get it done ..?

>

> int *pT= &ta[41];//the same as the last

> commente;

>

>pT++;//can this be done in java ?

> // if yes then write it down

> please;

> // if no.. then is their a way to

> get it done ..?

>

>ta= NULL;

> pe i find the answer...

No, pointer arithmetic cannot be done in Java. It's a higher-level language than that. That's not to say that the actual problem - as opposed to "how do I do pointer arithmetic?" which relates to a proposed solution to a problem, not a problem itself - can't be solved in Java

georgemca at 2007-7-12 17:38:38 > top of Java-index,Java Essentials,Java Programming...
# 15
T* tp=new T[54]; // worksT[] ta= new T[54];// does not even compile
BIJ001a at 2007-7-21 21:52:03 > top of Java-index,Java Essentials,Java Programming...