You are not logged in. Please login at www.codechef.com 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(System.in) ;
   Database obj = new Database();

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

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

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








}

}

asked 11 Oct '14, 19:13

shubham99's gravatar image

2★shubham99
2403932
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 Program.java", and everything will work fine.

link

answered 13 Oct '14, 00:07

aakashc31's gravatar image

4★aakashc31
22134
accept rate: 27%

toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×1,313

question asked: 11 Oct '14, 19:13

question was seen: 14,139 times

last updated: 13 Oct '14, 00:07