473,320 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Java compile error. Cannot Resolve symbol and incompatible types. HELP!! ASAP please

Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. class CAcc
  3. {
  4.     String name[]=new String[15];
  5.     long accno;
  6.     char type;
  7.     double Bal;
  8.  
  9.     CAcc(String Name,long Accno,char Type,double bal)
  10.     { 
  11.  
  12.          name=Name;
  13.          accno=Accno;
  14.          type=Type;
  15.          Bal=bal;
  16.          System.out.println("New account created with provided details");
  17.     } 
  18.     void deposit(double amnt)
  19.     {
  20.          Bal=Bal+amnt;
  21.          System.out.println("Amount deposited in Bank is"+amnt);
  22.     }
  23.      int withdraw(double amnt)
  24.     {
  25.         System.out.println("Old Balance in account is Rs."+Bal);
  26.         if(Bal>=amnt)  
  27.        {  
  28.             Bal=Bal-amnt;
  29.             System.out.println("New Balance in account is Rs."+Bal);
  30.             return(0);
  31.        }
  32.         else
  33.        {
  34.             return(1);
  35.        }    
  36.     }
  37.     void Check()
  38.     {
  39.         System.out.println("The Balance in Accno."+accno);
  40.         System.out.println("The Balance is"+Bal);
  41.     }
  42. }
  43.  
  44. class Bank
  45. {
  46.     public static void main(String []args)       
  47.     {
  48.         CAcc Manish= new CAcc ("Manish","200","S","15000.00");        
  49.         Manish.Check();
  50.         Manish.deposit(3000.00);
  51.         Manish.withdraw(1500.00);
  52.         Manish.Check();
  53.     }
  54. }        
  55.  
  56. My CODE is this and the error is here 
  57.  
  58. Bank.java:22: incompatible types
  59. found : java.lang.String
  60. required:java.long.string[]
  61.        name=Name
  62.             ^
  63. Bank.java:58:cannot resolve symbol
  64. symbol: constructor CAcc(java.lang.String,Java.lang.string,java.lang.string,java.lang.String)
  65. location: class CAcc
  66.     CAcc Manish=new CAcc("Manish","200","S","15000.00");
  67.                 ^
Feb 8 '15 #1
1 1643
chaarmann
785 Expert 512MB
In line 4 you define an array of strings, not a single string. Java is not like c++ wehre you have an array of chars as string. You just write
Expand|Select|Wrap|Line Numbers
  1. String name = "defaultValue"
Then the compile error in line 12 would go away. In Line 12, you were trying to assign the string "Name" to this array, which does not work. You can only assign arrays to arrays or Strings to Strings, but not mix it. Therefore you got the compile error
Expand|Select|Wrap|Line Numbers
  1. Bank.java:22: incompatible types
  2. found : java.lang.String
  3. required:java.long.string[]
  4.        name=Name
By the way, please be polite. No need to shout help and make pressure by typing ASAP. It should be self-understanding that we do it for free and only if we have some spare time and nobody can force us to answer. That's different from work where you pay for. Usually I do not answer these types of requests (and nobody else would, too), but today I was just in a funny mood. So I give you a good advice: if you want some feedback in the future, omit that sentence!
Feb 9 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Java script Dude | last post by:
I am investigating a solution to build all pages sent from my application servlet in UTF-8 encoding. From what I understand, I should be using HttpServletResponse.setCharacterEncoding("UTF-8"). The...
1
by: Tony Johansson | last post by:
Hello! I get compile error when compiling using the command javac from the command terminal window(CMD). I have just two classes which are called HelloWorld.java and Slask.java. I have both...
2
by: SDyke | last post by:
import com.ibm.as400.ui.framework.java.*; import java.awt.Frame; public class SampleApplication { public static void main(String args) { // Instantiate the bean object that...
3
by: toish | last post by:
I have a program, aaa.java which creates an instance of another class(bbb.java). both java files are in a package entitled 'diss' bbb.java compiles sucessfully aaa.java throws a cannot resolve...
3
by: adamrace | last post by:
Hi, i am fairly new to java and have been stuck on this for ages, basically i need to create a new object which gets a list of data from a text file, so i have this import java.io.*; ...
1
by: Elaine121 | last post by:
Hi i'm writing a program where you have to determine the smallest, number of distinctions and the average from an array of values. in my test class i get an error that says cannot find symbol -...
15
by: Seral1969 | last post by:
Hi, I'm new to Java... I've been trying to get one of my professor's examples to work... He says that the code is fine, but I keep getting 4 "cannot resolve symbol" errors when I try to compile...
3
by: Sindhu Rani | last post by:
i hav created 3 classes in 3 different files. am gettin an error durin compilation. wat shud i do??? C:\s\source>javac -d ..\classes devtestdrive.java devtestdrive.java:5: cannot resolve symbol...
2
Uncle Dickie
by: Uncle Dickie | last post by:
Hi All, I am getting the error: Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation. when I run a query I have...
3
by: darkseeker | last post by:
Hi guys, I'm working on my java assignment but I don't know what did I do wrong. I successfully compile the file Book.java but got the error cannot find symbol while compiling BookTest.java . Thank...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.