Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2016
    Posts
    93
    Rep Power
    0

    Default string cannot be resolved to a type error

    I don't understand why, even though it's already 2016, that Oracle hasn't made a string a built-in datatype, but what is the import statement for strings again?

    Java Code:
    import java.text.NumberFormat;
    //import statement for strings?
    public class Product {
    
    	//instance variables:
    	private string itemName;//string cannot be resolved to a type
    	private string Description;
    	private double price;
    	
    	//constructor:
    	
    }//end of class body

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: string cannot be resolved to a type error

    No need to import anything; the String class is in the java.lang package; note the capital 'S' in String ...

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    Xeroxis Labz is offline Member
    Join Date
    May 2016
    Location
    Puerto Rico
    Posts
    2
    Rep Power
    0

    Default Re: string cannot be resolved to a type error

    Exactly as stated by JosAH, the package gets implicitly imported by the Java compiler. Think about it, inside we have the most fundamental class for Java... the Object class.

  4. #4
    Join Date
    May 2016
    Location
    Brazil
    Posts
    16
    Rep Power
    0

    Default Re: string cannot be resolved to a type error

    As JosAH stated the type is called String, not string, and it's an object with lot's of methods for handling character sequences, check the API:

    https://docs.oracle.com/javase/8/doc...ng/String.html

Similar Threads

  1. "string cannot be resolved to a type" error
    By Sam_JavaTheHut5580 in forum New To Java
    Replies: 1
    Last Post: 05-23-2016, 08:04 AM
  2. cannot be resolved to a type
    By johnmerlino in forum New To Java
    Replies: 4
    Last Post: 06-05-2014, 12:22 AM
  3. Cannot be resolved to a type
    By Naxix in forum AWT / Swing
    Replies: 1
    Last Post: 03-18-2012, 12:16 PM
  4. Error: ConsoleProgram cannot be resolved to the type
    By petrohamadi in forum New To Java
    Replies: 5
    Last Post: 06-13-2011, 10:49 PM
  5. Replies: 4
    Last Post: 12-13-2010, 10:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •