• Register
1 vote



I started adopting the Java programming language a few days back. For the time being, I’ve written a java program that should print values from my StudentDatabase using an object of it. Inside my StudentDatabase, I have all the values I need to access. But the problem occurs when I am trying to execute the program. The compiler throws an error. It says string cannot be resolved to a type. I am attaching my codes snippet and error message below. Please, fix the error and save my time Thanks

import java.util.Scanner;

class StudentDatabase{
    string name;
    int age;
    long telephone;

public class MyProgram{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in) ;
        StudentDatabase myobject = new StudentDatabase();
        System.out.print("Enter Your Good Name: ");
        myobject.name= sc.nextLine();
        System.out.print("Enter Your Age: ");
        myobject.age = sc.nextInt();
        System.out.println("Enter Your 6 - Digit telephone Number: ");
        myobject.telephone = sc.nextLong();


And the error I am getting

MyProgram.java:4: error: cannot find symbol
    string name;
  symbol:   class string
  location: class StudentDatabase
1 error


12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

2 votes


You need to remind that, Java is a highly case sensitive language. In Java, the uppercase and lowercase letters are treated in different ways. You are getting that error because of violating the naming convention of java data-type. There is no such data-type as ‘string’. You wanted to write it as “String”. You can read the convention here

So, to fix the error, just change the data-type name from “string” to “String” and your program should run fine. 

Good Day!

13 9 6
94,260 points

Related questions

1 vote
1 answer 5 views
Problem; During my dynamic web project I got this error , any one who can tackle ? Controller cannot be resolved to a type.
asked Mar 25 PkGuy 23.5k points
0 votes
1 answer 3 views
Problem: Why it is android r cannot be resolved to a variable?
asked Apr 13 jamuna1 30.2k points
0 votes
1 answer 16 views
Problem: I just downloaded and introduced the new android SDK. I needed to make a basic application to test it.The wizard made this code: package eu.mauriziopz.gps; import android.app.Activity; import android.os.bundle; public class ggps extends Activity { /** Called when the ... .main); } } but eclipse showed me the given error: R cannot be solved setContentView(R.layout.main); Why is it so?
asked Feb 15 sasha 16.2k points
0 votes
1 answer 2 views
Problem: How to fix this error > The type of the expression must be an array type but it resolved to string
asked 4 days ago ummeshani 9k points
0 votes
1 answer 23 views
Any help or guidance would be much appreciated! Thank you
asked Dec 16, 2020 TeamScript 13.5k points
0 votes
0 answers 49 views
my program (java) is below. I wrote it with eclipse IDE. I still can&rsquo;t figure out the mistake. package com.in28minutes.firstjavaproject; public class MultiplicationTable { void print() { for (int i = 1; i <= 10; i++) { System. ... public class MultiplicationTableRunner { public static void main(String[] args) { MultiplicationTable instance = new MultiplicationTable(); instance.print(); } }
asked Feb 6 chathura2001 120 points
1 vote
1 answer 6 views
Problem: When I am develping a web app but getting this error: Javax.servlet.jsp.jspexception cannot be resolved to a type.
asked Apr 25 PkGuy 23.5k points
1 vote
1 answer 43 views
Problem : Why Eclipse is saying that my ArrayList cannot be resolved to a type : import.java.util.ArrayList; public class Campaign { private String candidateName; private ArrayList<DonorList> donors; public Campaign(String name) { //TODO Initialize all of the instance data candidateName = name; donors = new ArrayList<DonorList>(); }
asked Mar 28 Sabbir Hossain 14.6k points
0 votes
1 answer 7 views
Problem: when I run the following code it shows an error that the scanner cannot be resolved to type. I checked that JRE is installed and the version is 1.7 what else do I need to check? please help.
asked Mar 27 ummesalma 29.2k points
0 votes
1 answer 17 views
Problem: I need someone&rsquo;s help to fix it.file cannot be resolved to a type
asked Mar 22 Ifra 34.7k points