You are not logged in. Please login at to post your questions!


Java : String cannot be resolved to a type. What's wrong in my code block ?

import java.util.Scanner;

public class Database{

string name;
int age;
long tel;


public class Program {
public static void main(String[] args) {

   Scanner input = new Scanner( ;
   Database obj = new Database();

   System.out.print("Enter Your Name : "); input.nextLine();

   System.out.print("Enter Your Age : ");
   obj.age = input.nextInt();

   System.out.println("Enter Your 6 - Digit Telephone Number"); = input.nextLong();



asked 11 Oct '14, 19:13

shubham99's gravatar image

accept rate: 5%

Java is a case-sensitive language, that is, uppercase and lowercase letters are treated differently. Here "string" is not resolved because there is no class or data type named "string". The first letter is small. "String" is correct (notice the first letter 'S' is in upper case here). Also, you have defined two public classes in a single chunk of code. This is an error. Make the class named "Database" non-public, and save the file as", and everything will work fine.


answered 13 Oct '14, 00:07

aakashc31's gravatar image

accept rate: 27%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 11 Oct '14, 19:13

question was seen: 14,139 times

last updated: 13 Oct '14, 00:07