Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 New To Forums, and, unfortunately, Java.
Index -> Programming, Java -> Java Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CannotFindSymbol




PostPosted: Fri Jan 09, 2009 11:12 pm   Post subject: New To Forums, and, unfortunately, Java.

Just would like to start by saying hi and was recommended this forum by Insectoid.
anyways, to cut to the chase, I am doing my summative and the teacher has been away for a few days and hence not around to help me. Instead we got a useless substitute. So I've been hung up on this bit of code here:
Java:

import java.text.*;
import java.util.*;
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class Main {

   
    public static void main(String[] schmee) throws IOException {

        File Wurdz = new File ("Wurdz.txt");
        Scanner fyleInn = new Scanner (Wurdz);


        int MAXREC = 0;
        int recs = 0;
        //String wurdUp [] = new String [MAXREC];
        //ArrayList werds = new ArrayList( Arrays.asList( wurdUp ) );
        ArrayList werds = new ArrayList ( fyleInn );

       
        while (fyleInn.hasNext()) {       

            werds.add (fyleInn);
           
            recs++;
        }


    }

}


And the problem line in particular:

Java:

ArrayList werds = new ArrayList ( fyleInn );

It's bugging me about Symbol Not Found.
More specifically:
Java:

symbol  : constructor ArrayList(java.util.Scanner)
location: class java.util.ArrayList
        ArrayList werds = new ArrayList ( fyleInn );
Note: /Users/Tyler/Desktop/TylerFinalProject/src/tylerfinalproject/Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
BUILD FAILED (total time: 0 seconds)


The program is SUPPOSED to be a spellchecker where I import a file with a set database of words, since this file will never stop growing as I will constantly add more words, I want to make an array list since they can have extra elements added (for extra words). The Array is a 1 Dimensional String array where the words will be stored. I have a rough idea about how to do the rest of the program. Such as for comparing the words, when the user types in a word, it runs a check against the whole array in the form of a while loop (Keep it simple here since the teacher might get suspicious about who I got help from if I start throwing in second year-university stuff). At the first true condition it will prompt the user with a correct message and terminate. If none of the conditions are true then it will ask the user if they wish to enter the word into the database. If this is true it will ArrayList.add (WordTheyTyped) into the array. Then print out the whole array overwriting the existing data in the text file and updating it with the new word added. At least, that's what it's supposed to do.
Sponsor
Sponsor
Sponsor
sponsor
Vermette




PostPosted: Sat Jan 10, 2009 3:44 am   Post subject: Re: New To Forums, and, unfortunately, Java.

The compiler is telling you where your problem is:

Java:
constructor ArrayList(java.util.Scanner)


When the compiler is telling you your code has a problem with unchecked ops, you probably have casting (or lack thereof) issues going on. Since you're playing with a Collections class (ArrayList) int 1.5 code, it means you're missing Generics.

Take a look at wtd's big Java tutorial on the wiki, I believe some of his code samples can highlight where you're running into trouble:
http://wiki.compsci.ca/index.php?title=Introduction_To_Java
CannotFindSymbol




PostPosted: Sat Jan 10, 2009 12:32 pm   Post subject: Re: New To Forums, and, unfortunately, Java.

Wait, so instead of casting it like:
Java:

ArrayList werds = new ArrayList ( fyleInn );

I want to replace the second ArrayList with... what? In his tutorial he's using the array list to fill it with his previousNames class. He's using the ArrayList to store previous names in his example. I'm using the ArrayList to store words from scratch that are coming in from a file via a scanner. His code looked like:
Java:

ArrayList<Name> previousNames = bobsName.getPreviousNames();


It would look like he's getting his names from a bobsName class. Does this mean that I'd have to create a new class such as
Java:

public static void wordsINeed (String WordToGet) {
          //Do the scanner here
}

and then when it comes time to create the ArrayList in the mainline:
[syntax = "Java"]
ArrayList words = wordsINeed.getWordToGet();
[/syntax]

Let me know If I am reading this right or if I completely took it in the wrong direction.

Mod Edit: Fixed up broken tags
wtd




PostPosted: Sat Jan 10, 2009 1:26 pm   Post subject: RE:New To Forums, and, unfortunately, Java.

Try not to take offense at this suggestion, but given what I'm seeing in this thread, I am not sure you actually know much at all about Java and object-oriented programming.

Start from the beginning with my tutorial.
Insectoid




PostPosted: Sat Jan 10, 2009 8:14 pm   Post subject: RE:New To Forums, and, unfortunately, Java.

wtd, you are right. He, nor I, nor anyone in my class has any idea how Java works. I had no idea what OOP meant until I started Ruby. Java is just so finicky and inconsistent, it makes it difficult to learn OOP. CannotFindSymbol isn't really half bad at programming (rather good, actually), once he understands the concepts. I blame it on our teacher teaching a grade 11 and grade 10 class at the same time and being too nice to kick out students who just screw around for the whole period. There is a grade 10 course next semester, why are those kids in my class?
CannotFindSymbol




PostPosted: Sun Jan 11, 2009 10:59 am   Post subject: RE:New To Forums, and, unfortunately, Java.

I've messed around in C# for a while, but didn't do anything with it long enough that I forgot all about it. No offense taken and I'm still budding at Java. I just find a lot of it's inconsistencies a tad aggravating to the point where I might even go buy a copy of windows just to run bootcamp on this mac and, inherently, C#. For now though I have to get through this program. And lets just say I'm better off then pretty much everyone else in the class at Java, if that's an indicator of our program.
wtd




PostPosted: Sun Jan 11, 2009 12:32 pm   Post subject: RE:New To Forums, and, unfortunately, Java.

C# as a language is a bit of an improvement over Java. Its library is worse, though.

You could take a page from insectoid and check out Ruby.
[Gandalf]




PostPosted: Sun Jan 11, 2009 3:39 pm   Post subject: Re: RE:New To Forums, and, unfortunately, Java.

CannotFindSymbol @ 2009-01-11, 10:59 am wrote:
For now though I have to get through this program.

Alright then, for now I would suggest following wtd's suggestion and reading through his tutorial from the start. It's easy enough saying Java is inconsistent and giving up, but it's another thing doing your best to learn things properly. Learning why things are how they are, for better or worse, will also help you with your current program.
Sponsor
Sponsor
Sponsor
sponsor
CannotFindSymbol




PostPosted: Mon Jan 12, 2009 8:48 am   Post subject: RE:New To Forums, and, unfortunately, Java.

Ok. Here's the shakedown. I have to hand this in on Friday. I'm home today, so that gives me 4 days of school time to finish this program. I don't HAVE the time to re-learn Java from square one, only to use what I have. I'm not learning it because I want to or am learning it on my own here. I also DON'T have enough time to go learn Ruby, write an at least entry-level program, and hand it in before Friday. If I had my Druthers, I'd probably be learning Python or C++. But I don't have that comfort.
OneOffDriveByPoster




PostPosted: Mon Jan 12, 2009 10:51 am   Post subject: Re: RE:New To Forums, and, unfortunately, Java.

CannotFindSymbol @ Mon Jan 12, 2009 8:48 am wrote:
I don't HAVE the time to re-learn Java from square one, only to use what I have.
That's fine. Note that the previous replies mentioned Java 1.5. You are probably expecting Java 1.4.2 behaviour since that is what your school likely has. Try a search on this site (or with Google on this site) for "java 1.4 1.5". I recommend using Java 1.5+, but if you have not used it before and you are doing work for school, I advise against going with 1.5+ without preparation.
wtd




PostPosted: Mon Jan 12, 2009 12:13 pm   Post subject: RE:New To Forums, and, unfortunately, Java.

For the section on generics, which is the issue you're running into: http://wiki.compsci.ca/index.php?title=Introduction_To_Java#Generics
CannotFindSymbol




PostPosted: Mon Jan 12, 2009 6:35 pm   Post subject: Re: RE:New To Forums, and, unfortunately, Java.

OneOffDriveByPoster @ Mon Jan 12, 2009 10:51 am wrote:
CannotFindSymbol @ Mon Jan 12, 2009 8:48 am wrote:
I don't HAVE the time to re-learn Java from square one, only to use what I have.
That's fine. Note that the previous replies mentioned Java 1.5. You are probably expecting Java 1.4.2 behaviour since that is what your school likely has. Try a search on this site (or with Google on this site) for "java 1.4 1.5". I recommend using Java 1.5+, but if you have not used it before and you are doing work for school, I advise against going with 1.5+ without preparation.

I'm actually using NetBeans on a 4 month old mac.
VB3CK




PostPosted: Mon Jan 12, 2009 6:39 pm   Post subject: RE:New To Forums, and, unfortunately, Java.

Isn't this cheating since it is a semester project?
Meh who gives Razz COMSCI.Ca rocks Razz
wtd




PostPosted: Tue Jan 13, 2009 12:37 am   Post subject: RE:New To Forums, and, unfortunately, Java.

Referring someone to a general purpose reference is not cheating by any definition I am aware of.
CannotFindSymbol




PostPosted: Thu Jan 22, 2009 10:46 pm   Post subject: RE:New To Forums, and, unfortunately, Java.

Ok I have since figured out the problem, and didnt need the teacher. Finished project, and it worked like a charm.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: