1
/*     */   public static void printJoinChat(Player player) {
/*  41 */     FileConfiguration kitConfig = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "kit.yml"));
/*  42 */     List kitname = kitConfig.getStringList("KITS");
/*     */ 
/*  44 */     String vipkit = "";
/*  45 */     String norkit = "";
/*  46 */     for (String name : kitname) {
/*  47 */       ConfigurationSection kit = kitConfig.getConfigurationSection(name.toLowerCase());
/*  48 */       if (kit.getBoolean("VIP")) {
/*  49 */         if (vipkit == "")
/*  50 */           vipkit = name;
/*     */         else {
/*  52 */           vipkit = vipkit + ", " + name;
/*     */         }
/*     */       }
/*  55 */       else if (norkit == "")
/*  56 */         norkit = name;
/*     */       else {
/*  58 */         norkit = norkit + ", " + name;
/*     */       }
/*     */ 
/*     */     }

This code returns the error "Type mismatch: cannot convert from element type Object to String" at line 46. Why does this error come up?

2
  • you should specify List<String> kitname or else it will be taken as an Object Commented May 18, 2012 at 23:07
  • Start compiling with -xlint, then the compiler will tell you about things like this. Commented May 18, 2012 at 23:11

1 Answer 1

5

Change to this:

 List<String> kitname = kitConfig.getStringList("KITS");

Make sure that method returns a List<String> and not just a List.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.