Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Introductions.java not compiling, have I missed something?

this is the code

javac Iimport java.io.Console;

public class Introductions {

public static void main(String[] args) {
    Console console = System.console();
    // Welcome to the Introductions program!  Your code goes below here
    console.printf("Hello, My name is Taher"); 

} }

this is error I get when trying to compile

treehouse:~/workspace$ javac Introductions.java

Introductions.java:1: error: class, interface, or enum expected

javac Iimport java.io.Console;

^

1 error

treehouse:~/workspace$

thanks in advance

2 Answers

First: it is import java.io.Console;

In these first challanges you dont have to import the console or create a new instace of it. just use console.printf(YourStringHere);

thanks

Hey I need help with this code I keep getting an error: class, interface, enum, expected? Let me first explain what im trying to do? I am trying to create a program that will simple ask my daughter a set of question randomly, calculate the answers that she inputs as correct or incorrect, End once the five questions are asked and final tally up a score of correct/incorrect answers. can anybody help me please? here is what ive started below:

import java.io.Console; import java.util.Random;

public static final void main(String[] args) {
  int MAX_QUESTIONS = 5;
    Console console = System.console();
    String[] questions = Questions.shuffled();
    int numberOfQuestion = 0;
    String numberOfCorrectAnswers = false;
    String numberOfIncorrectAnswers = false;
    String getAnswers;
    String startAskQuestions;
    Random question = new Random(startAskQuestions);
    String askQuestions;


public class lesson {
public String startAskQuestions;

public String startAskQuestion {
    questionFirst = console.out.println("What is your name? ");
    questionSecond = console.out.println("What is father's name? ");
    questionThird = console.out.println("What is your mother's name? ");
    questinFourth = console.out.println("What is your address? ");
    questionFifth = console.out.println("What is your brother's name? "); 

} }

while (MAX_QUESTIONS < 5) {
        String startAskQuestions = questions.shuffled();
    } if ( numberOfCorrectAnswers > numberOfCorrectAnswers) {
        continue;
    }

    String askQuestions = startAskQuestions 

} 

}