Jump to content

Help with Java?

Corruption
Go to solution Solved by Neil,

Could someone move this to the programming subforum?

@op: wrap your code In code tags so it gets highlighted.

In java , you cannot have two main classes in the same file (normally).

You will want to create a new class (file) in Eclipse.

Also, your terminology is a bit... Odd. You're not "making a letter equal" something. You're initializing a variable to a value.

so im using Eclipse and made a new Java class that looked something like this

import java.util.Scanner;

public class main {

public static void main(String[] args){

 

    // this is to quote text directly

    System.out.println("Hello World!");

 

    // this is to make a letter equal a number

    int x = 5;

    System.out.println(x);

 

    // this is to make a letter equal a decimal

    float y = 5.6F;

    System.out.println(y);

 

    // this is to make a command=false

    boolean FallingDown = false;

    System.out.println(FallingDown);

 

    // this is to make a command true

    boolean FallingUp = true;

    System.out.println(FallingUp);

 

    // this is to make a letter equal another letter

    char z = 'R';

    System.out.println(z);

 

    // this is to make a letter equal a symbol

    char t = '^';

    System.out.println(t);

 

    // this is to make a letter equal anything

    String A = "A 1 1.5 *";

    System.out.println(A);

 

    // this is to make a float command an integer and to make console ignore 

the decimal and the number after it int q = (int)6.9; System.out.println(q);

    // this is to add, divide, multiply, and subtract the defined letter

    int c = 8;

    c /= 7;

 

    System.out.println©;

    // this is to have an interactive chat box that tells you what you wrote

    Scanner b = new Scanner(System.in);

    String input;

 

    System.out.println("Enter Whatever Here");

    input = b.nextLine();

    System.out.println("You Entered: " + input + ".");

 

}

}

which ended up becoming this

Hello World!

5

5.6

false

true

R ^ A 1 1.5 * 6 1

Enter Whatever Here

f

You Entered: f.

but now i closed that class out and started a new on that looks like this

public class MainClass {

public static void mainclass(String[] args){

 

    int age = 5;

    if(age==5){

        System.out.println("You Are Five!");

    }

}

}

but the console from the last class pops up like this

Hello World!

5

5.6

false

true

R ^ A 1 1.5 * 6 1

Enter Whatever Here

f

You Entered: f.

You Are 5!

 

how do i get rid of the old one?

Taking Falling to whole new Heights

Link to comment
Share on other sites

Link to post
Share on other sites

Could someone move this to the programming subforum?

@op: wrap your code In code tags so it gets highlighted.

In java , you cannot have two main classes in the same file (normally).

You will want to create a new class (file) in Eclipse.

Also, your terminology is a bit... Odd. You're not "making a letter equal" something. You're initializing a variable to a value.

--Neil Hanlon

Operations Engineer

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×