A constructor does not have a return type. Your EncounterGenerator
constructor attempts to return a String.

Since you are new to Java, I heartily recommend spending time learning
Java before getting into Android development. Here is a blog post
where I outline some key Java topics that newcomers to Java should
know before starting with Android:

http://commonsware.com/blog/2010/08/02/java-good-parts-version.html

On Fri, May 13, 2011 at 3:12 PM, cmt <[email protected]> wrote:
> I added a new class to my Android project and then declared it in my
> main .java file like this:
>
> Encounter EncounterGenerator;
>
> However, I'm getting this error:
>
> "Encounter cannot be resolved to a type"
>
> My new class is in a separate file with the code listed below.
>
> Is there anything I'm doing wrong?
>
> Thanks!
>
> package myStuff.HelloAndroid;
>
> public class EncounterGenerator {
>
>        public String EncounterGenerator() {
>                String encounterText;
>                int encounter;
>                encounter = (int)(Math.random() * 3);
>
>                switch (encounter) {
>                case 0:  encounterText = "Encounter # 1";
>                                 break;
>                case 1:  encounterText = "Encounter # 2";
>                                 break;
>                case 2:  encounterText = "Encounter # 3";
>                                 break;
>                default: encounterText = "Encounter # 4";
>                }
>                return encounterText;
>        }
> }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 3.0 Programming Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to