main

Why the out put of below code is Thread[main,5,main]

冷暖自知 提交于 2019-12-04 07:01:03
问题 public class test1 { public static void main(String[] args) { // TODO Auto-generated method stub Thread t = Thread.currentThread(); System.out.println(t); } } Why the output of above code is - Thread[main,5,main] ? Please Explain 回答1: Because thread.toString() returns a string representation of this thread, including the thread's name, priority, and thread group. 回答2: Returns a string representation of this thread, including the thread's name, priority, and thread group. Source: https://docs

What Exacly (args.length>0) means?

人走茶凉 提交于 2019-12-04 06:35:37
问题 This may be simple to you people but as i am new to java, so i want know actually what is going on in the following part? if (args.length > 0) { file = args[0]; } public class DomTest1 { public static void main(String[] args) { String file = "test1.xml"; if (args.length > 0) { file = args[0]; } } } 回答1: Those are called command line arguments , which you get as a String array in your program. Here is the Oracle tutorial A Java application can accept any number of arguments from the command

Main method not found in class/illegal start of expression

自古美人都是妖i 提交于 2019-12-04 05:27:28
问题 I am new to all of this and really only have a basic understanding of coding in general. I am actually trying to use a java code that was published in ChemMedChem (dx.doi.org/10.1002/cmdc.200900317 in the supporting information) i have all the appropriate programs/jar files they use (from ChemAxon) i am able to copy the code and compile it to a class file with no issues: javac -classpath C:\jarfolder\MarvinBeans-plugin.jar;C:\jarfolder\MarvinBeans.jar; MQN.java though i do get: Note: MQN.java

C# - Calling a function from static main

狂风中的少年 提交于 2019-12-04 05:16:05
问题 my question is probably very basic but I did not find an answer... I wrote a function (public checkSomething that gets 2 strings) in program.cs when I tried to call this function from static main I got this error: "An object reference is required for a non-static field, method or property 'checkSomething(string,string)' ". However,when I changed my main to Public (and not static)- there is no error. Why this happen? What is better - to have a Static main or not? Why would it even matter?

Multiple definition of main()

扶醉桌前 提交于 2019-12-04 05:08:27
问题 Hi guys trying to use two main() and getting this error multiple definition of main(). I renamed my main functions then why is this error and also first defined here for my print(). header file: #ifndef TOP_H_ #define TOP_H_ #include <stdio.h> #include <string.h> #define onemain main #define twomain main inline void print(); #endif /* TOP_H_ */ c file one: #include "top.h" void print(); int onemain() { print(); return 0; } void print() { printf("hello one"); } c file two: #include "top.h"

“global main” in Assembly

天涯浪子 提交于 2019-12-04 05:04:55
I came across this snippet of code: section .text global main ;must be declared for linker (gcc) and then there is a function called main after this line: main: ;tell linker entry point but i don't seem to understand what global main means, and the comment doesn't seem to help much... i am using this site as a reference to Assembly language programming. i can analyse that main refers to the function main, but i don't understand the use of the global keyword... thank you in advance... global main basically means that the symbol should be visible to the linker because other object files will use

How many arguments does main() have in C/C++

谁说我不能喝 提交于 2019-12-04 04:36:35
What numbers of arguments are used for main ? What variants of main definition is possible? Brian R. Bondy C++ Standard: ( Source ) The C++98 standard says in section 3.6.1.2 It shall have a return type of type int, but otherwise its type is implementation-defined. All implementations shall allow both the following definitions of main: int main() and int main(int argc, char* argv[]) Commonly there are 3 sets of parameters: no parameters / void int argc, char ** argv int argc, char ** argv, char ** env Where argc is the number of command lines, argv are the actual command lines, and env are the

Why are we allowed to have a final main method in java?

浪尽此生 提交于 2019-12-04 04:13:30
Can anyone tell me the use of making main method as final in java. while this is allowed in java public static final void main(String[] args) { } I dont see any use of making it final. anyways it is static so we can not override it. aioobe Adding final to a static method can actually make a difference. Consider the following code: class A { public static void main(String[] args) { System.out.println("A"); } } class B extends A { public static void main(String[] args) { System.out.println("B"); } } class C extends B { } public class Test { public static void main(String[] args) { C.main(args);

How to return an exit code from the main block in Nim?

只愿长相守 提交于 2019-12-04 03:33:26
问题 In Nim, to write code that executes as a sort of main function, you do (similar to the is main checks in Python): when isMainModule: echo ("Hello, Nim!") However, for the life of me, I can't figure out how to return an error code. Traditionally there has always been an option to make main functions return int , but since this is not actually in a proc , it doesn't seem like you can return ; the only thing I've figured out how to do is to raise an exception. Surely there is a way to just

Memory allocation and **argv argument [closed]

自作多情 提交于 2019-12-04 03:14:47
Closed . This question needs details or clarity. It is not currently accepting answers. Learn more . Want to improve this question? Add details and clarify the problem by editing this post . Closed 5 years ago . I know for what we use this argument, and I even know how to work with the argument. There is only one things I still do not understand. How a program allocate memory for strings which came from the input. **argv has no allocated memory at the start of the program, isn't it? I was expecting segfault, but it didn't happen. Does anybody know how this memory allocation work? The C/C++