简体   繁体   中英

compiling Java error, cannot get constructor working

I am trying to code a simple bit of java but i cannot get it to compile I have defined the objects within my class as so

    public class teams
    {
      public char sponsor;
      public char tires;

I am trying to set the default value of class sponsor to N/A

      public teams()
      {
      this.sponsor = "N/A";
      }

Can anyone figure out why it wont work? Im fairly new to java and i know this is probably extremely simple, any help would be appreciated!

EDIT So thanks to Kevin Esche, I managed to get it to compile by using,
this.sponsor = 'N';

How would I get the term N/A instead of just N? Would I use unicode?, and if yes how do you format it?

Either you make your sponsor a String

 public String sponsor;

Or you store only one character in it:

    sponsor = 'X';

Good Luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM