Question:
java programme showing arbit output.........!!!!!!!!!!?
2013-06-23 06:56:22 UTC
class td{
public static void main (String args[]){
int a[][]={{1,2,3},{1},{2,3,4}};
int b[][]={{1,2,3,4},{2,3,4},{1,2}};
}

its showing no runtime error.
but output is
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.

-cp
-classpath
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D=
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:...|:]
-enableassertions[:...|:]
enable assertions with specified granularity
-da[:...|:]
-disableassertions[:...|:]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:[=]
load native agent library , e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:[=]
load native agent library by full pathname
-javaagent:[=]
load Java programming language agent, see java.lang.instrument
-splash:
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.

Process completed.
Why????????????/
Three answers:
AnalProgrammer
2013-06-23 07:36:17 UTC
Your main method is not wrong.

That is the help text from the java command.



You have just typed java on the command line.



You need to type

java [-options] myprogram [args...]



Have fun.
husoski
2013-06-23 15:49:21 UTC
That's not arbitrary. It's usage information for the java command itself. You get that in response to any of the commands:



java

java -h

java -help



The second two can be followed by a class name and arguments, maybe other options, but they will be ignored. All you will get is that "help" display.



So, take a look at how you are trying to run that class. If you are typing "-h" or "-help", don't. If you are running from the command line, the syntax is:



java td



That's "java" followed the main class name (not the file name) and any arguments for the args[] array after that (none in this example.) Separate those with spaces or tabs.
2013-06-23 14:03:30 UTC
Main method is wrong



its supposed to be



public static void main(String [] args){

// code to execute goes here



}


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...