need help with convertng

From: Angela K (crxgurl_at_shaw.ca)
Date: 10/25/03


Date: Sat, 25 Oct 2003 19:26:48 GMT

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



Relevant Pages

  • RE: Controling Modal Dialogs (Solution)
    ... doesn't return until the 'modal' browser returns. ... string varOptions) ... public void DocumentComplete ... int rc = winDisp.Invoke(rgDispId, ref guid, 0, ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: OO is not that great: many repeated codes
    ... Instances of both classes have to be able to handle the driveCarWell message - how they do handle it is implementation-dependant, and doesn't necessarily requires implementing the method in each class. ... void cookDeliciousFood() ... int average ... But it's true that Java has no support for the former and forbid the later. ...
    (comp.object)
  • Re: question about assigning null to a reference object
    ... String getAuthor() ... int getPages() ... void setAuthor ... b.setTitle("Thinking in Java 54th Edition"); ...
    (comp.lang.java.help)
  • Re: question about assigning null to a reference object
    ... String getAuthor() ... void setAuthor ... b.setTitle("Thinking in Java 4th Edition"); ...
    (comp.lang.java.help)
  • Re: nativeMethod error
    ... private void InitializeComponent() ... public int cmdID; ... bool TopLevelContainer ... string LocationName ...
    (microsoft.public.dotnet.languages.csharp)