473,406 Members | 2,705 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,406 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 1654
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.