Results 1 to 4 of 4
  1. #1
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    100
    Rep Power
    0

    Default Why this error coming again and again.....!!!

    i create a new file

    File hi=new File("C:/new.txt");
    hi.createNewFile();

    why it showing this error again and again even i changed reference variable name...

    orr i did not wrote these lines like "fi.exists()","fi.getName()"



    C:\Users\Dev Vivek\Desktop>javac joke.java
    joke.java:8: error: constructor File in class File cannot be applied to given ty
    pes;
    File hi=new File("D://new.txt");
    ^
    required: no arguments
    found: String
    reason: actual and formal argument lists differ in length
    .\File.java:8: error: constructor File in class File cannot be applied to given
    types;
    File fi=new File("D:/data.txt");
    ^
    required: no arguments
    found: String
    reason: actual and formal argument lists differ in length
    .\File.java:10: error: cannot find symbol
    fi.createNewFile();
    ^
    symbol: method createNewFile()
    location: variable fi of type File
    .\File.java:11: error: cannot find symbol
    System.out.println("Is File exist :"+fi.exists());
    ^
    symbol: method exists()
    location: variable fi of type File
    .\File.java:12: error: cannot find symbol
    System.out.println("File name :"+fi.getName());
    ^
    symbol: method getName()
    location: variable fi of type File
    .\File.java:13: error: cannot find symbol
    System.out.println("Is File can write :"+fi.canWrite());
    Last edited by vknehra10; 04-20-2017 at 08:03 AM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    25

    Default Re: Why this error coming again and again.....!!!

    These bits of those errors:
    .\File.java:10: error: cannot find symbol

    imply that you have your own File,java class, which is being used instead of the one in java.io.
    This is one of the problems of naming your classes the same as common core classes.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    100
    Rep Power
    0

    Default Re: Why this error coming again and again.....!!!

    you mean im using

    import java.myclass.*;

    or i have to use

    import java.io.*;

    right aa?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    25

    Default Re: Why this error coming again and again.....!!!

    Do you have a class in that directory called File.java?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Java Error coming up
    By jank3538 in forum New To Java
    Replies: 11
    Last Post: 05-18-2012, 09:14 PM
  2. Replies: 8
    Last Post: 11-13-2011, 09:51 PM
  3. Replies: 4
    Last Post: 11-10-2011, 05:43 PM
  4. i cant undersatand y this error is coming
    By RajeshReddy in forum AWT / Swing
    Replies: 0
    Last Post: 07-21-2011, 02:53 PM
  5. Jax is coming to the us!!!
    By blease87 in forum Reviews / Advertising
    Replies: 0
    Last Post: 03-04-2011, 12:21 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
  •