Results 1 to 6 of 6
- 10-05-2013, 04:58 AM #1
Member
- Join Date
- Oct 2013
- Posts
- 2
- Rep Power
- 0
Why is my java program giving this error??
So i'm new to java and i'm having a bit of problem with my code when i try converting char to char[] array it gives me this error:
The constructor example(char[]) is undefined
Here is the main code:
Java Code:read = new Scanner(new BufferedReader(new FileReader("Example.txt"))); while (read.hasNext()) { String str = read.next(); char[] myChar = str.toCharArray(); example arrayChar = new Dexmaple(myChar); }
Java Code:private char[] reading = new char[20]; public example(char myChar) { for(int i = 0; i < reading.length; i++) { this.reading[i] = myChar; } }
- 10-05-2013, 05:03 AM #2
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,170
- Rep Power
- 12
Re: Why is my java program giving this error??
You are not showing enough of your code for anyone to be able to properly help you. However, from what I see it looks like you are assigning myChar to each position in reading.
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 10-05-2013, 05:12 AM #3
Member
- Join Date
- Oct 2013
- Posts
- 2
- Rep Power
- 0
Re: Why is my java program giving this error??
Yeh thats exactly what i'm trying to do i want to read character by charcter from the file and put them into array to compare to another array i have set up
Say fro example in my file i got this following info
A T N D F G J P L
S T N D R Y J I L
and so on
and my array which i'm comparing to
private char[] correctAnswers = { 'A', 'T', 'N', 'D', 'F', 'Y', 'J', 'I', 'L' };
- 10-05-2013, 05:40 AM #4
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,170
- Rep Power
- 12
Re: Why is my java program giving this error??
But you need to show all of your code, including your class declarations, etc.
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 10-06-2013, 05:07 AM #5
- 10-06-2013, 05:42 PM #6
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,170
- Rep Power
- 12
Re: Why is my java program giving this error??
Ah! I was focusing on Dexmaple.
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
Similar Threads
-
Java imports not giving error when program ran within my Work network domain.
By pcmonto in forum New To JavaReplies: 3Last Post: 03-01-2013, 06:16 PM -
My code keeps giving me NullPointerException error
By linx2001 in forum New To JavaReplies: 4Last Post: 11-07-2012, 04:47 PM -
JavaCompiler giving an error WITHOUT ide
By divs1210 in forum Advanced JavaReplies: 9Last Post: 04-09-2011, 01:04 AM -
Java code giving error
By alfarida in forum New To JavaReplies: 3Last Post: 11-10-2010, 07:11 PM -
MidletSample program giving java/lang/ClassFormatError: Bad version informatan error
By madhuchannama in forum Sun Java Wireless ToolkitReplies: 1Last Post: 07-23-2010, 02:42 PM
Bookmarks