Answer to Question #4256 in Java | JSP | JSF for DANIELLE

Question #4256
Below is the start of my program but i need to have the filename of yournamehw1.java.

import java.util.Scanner;

public class Divide {

public static void main (String args [] ) {

make kybd = new Scanner (System.in);

System.out.print("Enter number 1: ");
1
Expert's answer
2011-10-04T10:24:57-0400
There a some constrains in Java:
Only one "public class" can be in file. So
you can not write:
public class Cl1
{
}
public class
Cl2
{
}
in same file.

Also name of file must be the same as name
of "public class". So if you write
public class Cl1
{
}
it must be
written in Cl1.java.

So, you can rename your class to yournamehw1, or
rename file to
Divide.java. It is also possible to create public class
yournamehw1 in
yournamehw1.java and class Divide(not public) in
yournamehw1.java, but
it will be visible only in yournamehw1.java.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS