Whoever loves C++ and java programming, come here

Discussion in 'C++' started by Angela K, Oct 25, 2003.

  1. Angela K

    Angela K Guest

    I need to translate this code into java, can anyone do it?

    #include <iostream.h>
    #include "LinkedList.h"
    #include "mystring.h"


    template <class Object>

    void printList(const List<Object> & theList) {

    if(theList.isEmpty())

    cout << "The List is Empty, Dude!!" << endl;

    else {

    ListItr<Object> itr = theList.first();

    for( ; !itr.isPastEnd(); itr.advance())

    cout << itr.retrieve() << " ";

    } //printing list in else statement

    cout << endl;

    } // print list

    int main() {

    string x;

    List<string> myList;

    ListItr<string> theItr = myList.zeroth();

    int i = 0;

    printList(myList);


    cout << "Enter string values, seperated by whitespace." << endl;

    cout << "ctrl-d by itself on a line will terminate the process." << endl;

    cout << "Watch the List Building Up in Progress!!" << endl;

    while (cin >> x) {

    myList.insert(x, theItr);

    printList(myList);

    theItr.advance();

    i++;

    }

    cout << endl;

    cout << "Traverse the Entire List.Remove the names(nodes) that begin with

    the character" << endl;

    cout << "\"a\"" << endl;

    cout << "Watch the List Shrinkage in Progress!!" << endl;

    cout << endl;



    string y;

    string a = "a";



    ListItr<string> tItr = myList.first();

    for( ; !tItr.isPastEnd(); tItr.advance()) {

    y = tItr.retrieve();

    if(y[0] == a[0]) {

    myList.remove(y);

    printList(myList);

    }

    }
    return 0;

    } //main
     
    Angela K, Oct 25, 2003
    #1
    1. Advertising

  2. Angela K

    Moonlit Guest

    Hi,

    "Angela K" <> wrote in message
    news:Y6Amb.178112$pl3.106284@pd7tw3no...
    > I need to translate this code into java, can anyone do it?
    >


    No!

    Java (like C#) is just another C++ clone without the good stuff.

    Never understand why they didn't just use C++ to create applets.

    However with a lot more typing every C++ program can be turned into a java
    program.

    Use java containers instead of C++ templates, have a look at the
    documentation at http://www.javasoft.com

    This newsgroup is about the C++ language maybe you should ask this question
    in a java oriented group.

    Regards, Ron AF Greve.



    > #include <iostream.h>
    > #include "LinkedList.h"
    > #include "mystring.h"
    >
    >
    > template <class Object>
    >
    > void printList(const List<Object> & theList) {
    >
    > if(theList.isEmpty())
    >
    > cout << "The List is Empty, Dude!!" << endl;
    >
    > else {
    >
    > ListItr<Object> itr = theList.first();
    >
    > for( ; !itr.isPastEnd(); itr.advance())
    >
    > cout << itr.retrieve() << " ";
    >
    > } //printing list in else statement
    >
    > cout << endl;
    >
    > } // print list
    >
    > int main() {
    >
    > string x;
    >
    > List<string> myList;
    >
    > ListItr<string> theItr = myList.zeroth();
    >
    > int i = 0;
    >
    > printList(myList);
    >
    >
    > cout << "Enter string values, seperated by whitespace." << endl;
    >
    > cout << "ctrl-d by itself on a line will terminate the process." <<

    endl;
    >
    > cout << "Watch the List Building Up in Progress!!" << endl;
    >
    > while (cin >> x) {
    >
    > myList.insert(x, theItr);
    >
    > printList(myList);
    >
    > theItr.advance();
    >
    > i++;
    >
    > }
    >
    > cout << endl;
    >
    > cout << "Traverse the Entire List.Remove the names(nodes) that begin

    with
    >
    > the character" << endl;
    >
    > cout << "\"a\"" << endl;
    >
    > cout << "Watch the List Shrinkage in Progress!!" << endl;
    >
    > cout << endl;
    >
    >
    >
    > string y;
    >
    > string a = "a";
    >
    >
    >
    > ListItr<string> tItr = myList.first();
    >
    > for( ; !tItr.isPastEnd(); tItr.advance()) {
    >
    > y = tItr.retrieve();
    >
    > if(y[0] == a[0]) {
    >
    > myList.remove(y);
    >
    > printList(myList);
    >
    > }
    >
    > }
    > return 0;
    >
    > } //main
    >
    >
    >
    >
    >
     
    Moonlit, Oct 25, 2003
    #2
    1. Advertising

  3. Angela K

    Gregg Guest

    [OT] Re: Whoever loves C++ and java programming, come here

    "Moonlit" <> wrote in
    news:3f9ad4ad$0$58707$4all.nl:

    > Hi,
    >
    > "Angela K" <> wrote in message
    > news:Y6Amb.178112$pl3.106284@pd7tw3no...
    >> I need to translate this code into java, can anyone do it?
    >>

    >
    > No!
    >
    > Java (like C#) is just another C++ clone without the good stuff.
    >


    No, they are not clones of C++. They are very different languages with
    different design goals that have only superficial (mainly syntactic)
    similarities to C++. You might have an argument that C# is a clone of
    Java, though.

    > Never understand why they didn't just use C++ to create applets.
    >


    It's been done. That's what ActiveX usually is.

    Gregg
     
    Gregg, Oct 25, 2003
    #3
  4. Angela K escribió:

    > I need to translate this code into java, can anyone do it?


    How much do you pay for?

    Regards.
     
    =?iso-8859-1?Q?Juli=E1n?= Albo, Oct 25, 2003
    #4
  5. Angela K

    DvDmanDT Guest

    Re: [OT] Re: Whoever loves C++ and java programming, come here

    Not C++, but C... Not clones, but members of 'the C family'...
    "Gregg" <> skrev i meddelandet
    news:Xns941FA3C2F5940gregginvalidinvalid@207.69.154.206...
    > "Moonlit" <> wrote in
    > news:3f9ad4ad$0$58707$4all.nl:
    >
    > > Hi,
    > >
    > > "Angela K" <> wrote in message
    > > news:Y6Amb.178112$pl3.106284@pd7tw3no...
    > >> I need to translate this code into java, can anyone do it?
    > >>

    > >
    > > No!
    > >
    > > Java (like C#) is just another C++ clone without the good stuff.
    > >

    >
    > No, they are not clones of C++. They are very different languages with
    > different design goals that have only superficial (mainly syntactic)
    > similarities to C++. You might have an argument that C# is a clone of
    > Java, though.
    >
    > > Never understand why they didn't just use C++ to create applets.
    > >

    >
    > It's been done. That's what ActiveX usually is.
    >
    > Gregg
    >
     
    DvDmanDT, Oct 26, 2003
    #5
  6. Angela K

    Moonlit Guest

    Re: [OT] Re: Whoever loves C++ and java programming, come here

    "Gregg" <> wrote in message
    news:Xns941FA3C2F5940gregginvalidinvalid@207.69.154.206...
    > "Moonlit" <> wrote in
    > news:3f9ad4ad$0$58707$4all.nl:
    >
    > > Hi,
    > >
    > > "Angela K" <> wrote in message
    > > news:Y6Amb.178112$pl3.106284@pd7tw3no...
    > >> I need to translate this code into java, can anyone do it?
    > >>

    > >
    > > No!
    > >
    > > Java (like C#) is just another C++ clone without the good stuff.
    > >

    >

    Considering the syntax I think of it as a clone of C++. It is also very easy
    to learn if you already know C++. This is not a language they come up with
    without looking at C++.

    > No, they are not clones of C++. They are very different languages with
    > different design goals that have only superficial (mainly syntactic)
    > similarities to C++. You might have an argument that C# is a clone of
    > Java, though.
    >
    > > Never understand why they didn't just use C++ to create applets.
    > >

    >
    > It's been done. That's what ActiveX usually is.


    No, ActiveX only runs in IE. At the moment it is not as widely accepted as
    Java.

    >
    > Gregg
    >


    Regards, Ron AF Greve.
     
    Moonlit, Oct 26, 2003
    #6
  7. Angela K

    Gregg Guest

    Re: [OT] Re: Whoever loves C++ and java programming, come here

    "Moonlit" <> wrote in
    news:3f9b1ee0$0$58708$4all.nl:

    >
    > "Gregg" <> wrote in message
    > news:Xns941FA3C2F5940gregginvalidinvalid@207.69.154.206...


    [...]

    >>
    >> > Never understand why they didn't just use C++ to create applets.
    >> >

    >>
    >> It's been done. That's what ActiveX usually is.

    >
    > No, ActiveX only runs in IE. At the moment it is not as widely
    > accepted as Java.
    >
    >>
    >> Gregg
    >>

    >
    > Regards, Ron AF Greve.
    >


    Not "no". I meant exactly what I wrote, that it has been done. I said
    nothing about how universal or widely accepted it is.

    Gregg
     
    Gregg, Oct 26, 2003
    #7
  8. Angela K

    Mad Hamish Guest

    Re: [OT] Re: Whoever loves C++ and java programming, come here

    On Sun, 26 Oct 2003 02:09:54 +0100, "Moonlit"
    <> wrote:

    >
    >"Gregg" <> wrote in message
    >news:Xns941FA3C2F5940gregginvalidinvalid@207.69.154.206...
    >> "Moonlit" <> wrote in
    >> news:3f9ad4ad$0$58707$4all.nl:
    >>
    >> > Hi,
    >> >
    >> > "Angela K" <> wrote in message
    >> > news:Y6Amb.178112$pl3.106284@pd7tw3no...
    >> >> I need to translate this code into java, can anyone do it?
    >> >>
    >> >
    >> > No!
    >> >
    >> > Java (like C#) is just another C++ clone without the good stuff.
    >> >

    >>

    >Considering the syntax I think of it as a clone of C++. It is also very easy
    >to learn if you already know C++. This is not a language they come up with
    >without looking at C++.
    >


    Much of the syntactic similarities between Java and C++ predate C by a
    fair while.
    --
    "Hope is replaced by fear and dreams by survival, most of us get by."
    Stuart Adamson 1958-2001

    Mad Hamish
    Hamish Laws
     
    Mad Hamish, Oct 26, 2003
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. eric bin
    Replies:
    1
    Views:
    289
    Morris Dovey
    Nov 5, 2003
  2. Martin Maney

    Ubuntu Linux loves Python

    Martin Maney, Oct 2, 2004, in forum: Python
    Replies:
    8
    Views:
    8,274
    Alex Martelli
    Oct 29, 2004
  3. Jamey Cribbs

    An Ode To My Two Loves

    Jamey Cribbs, Feb 5, 2005, in forum: Python
    Replies:
    7
    Views:
    334
    Mike Meyer
    Feb 9, 2005
  4. Kobu
    Replies:
    25
    Views:
    726
    Mike Wahler
    Jan 23, 2005
  5. George Hester
    Replies:
    1
    Views:
    120
    Richard Cornford
    Dec 10, 2003
Loading...

Share This Page