Questions tagged [main]
In many programming languages, the main function, subroutine, or method marks the entry point of the program. It is generally the first-programmer-written function run when a program starts.
2,912
questions
0
votes
0
answers
30
views
Junit thread not terminate as java main method do [duplicate]
Example1
A junit test method. This will not print finally.
@Test
public void junit_Thread() {
new Thread(new Runnable() {
@Override
public void run() {
System.out....
-1
votes
0
answers
25
views
syntax error, unexpected identifier "count", expecting ":" Laravel [closed]
So I'm trying to make a total users count in laravel 9 but when I finished with it I got this error syntax error, unexpected identifier "count", expecting ":"
0
votes
0
answers
17
views
JUnit testing:How to write JUnit test cases for main method?I have tried many times to write JUnit test cases to call main method.Please help me out
Here is my code to reverse a number.
package BasicTesting;
import java.util.*;
public class revNumber {
public static void main(String args[]){
revNumber.main(args);
...
1
vote
2
answers
95
views
Why to put argc argv arguments in main when they never accessed?
I often see programs where people put argc and argv in main, but never make any use of these parameters.
int main(int argc, char *argv[]) {
// never touches any of the parameters
}
Should I do so ...
-1
votes
0
answers
39
views
When running rails run: bin/rails:3:in `require_relative': cannot load such file -- C:../config/boot (LoadError) from bin/rails:3:in `<main>'
I want to create an application occupying rails and since I also want to run it, when doing so I get this `require_relative' error: cannot load such file. I've searched for options but still can't ...
-2
votes
2
answers
30
views
Manipulating Variable Given to Void Function in C
Is there a way to implement that sort of Code
#include<stdio.h>
void func(int a)
{
a++;
}
int main()
{
int a=0;
func(a);
printf("%d", a);
return 0;
}
The ...
0
votes
0
answers
15
views
TaskExecutionException when i try to throw exception in main method
I'm trying run with code with gradle and without it.
public class Example {
public static void main(String[] args) throws RuntimeException {
throw new RuntimeException();
}
}
With ...
0
votes
1
answer
25
views
How do I correctly format my code to run this menu program in Java? [closed]
This is a beginner question. I'm about to start an online bootcamp and am stuck on my last pre-work project (which is a cumulation of everything we've been instructed to self-teach ourselves). I'm ...
0
votes
0
answers
6
views
How to read the file to my polygon shapes
so im trying to save the paint of my polygon shapes and got this constructor error. Are there suppose to be any values in them?
enter image description here
-2
votes
2
answers
44
views
Could you help me with this error "The method in undefined for the type"?
I was trying to populate an Arraylist using asList() but I I cant understand the error Eclipse is giving me, I read other solutions but I dont know to use them for my case
package arraylistvirtuale;
...
0
votes
1
answer
57
views
if __name__ == "__main__": failing; why won't __main__ call my classes?
I have been simplifying this code and I am without words. Simply put, the file will not run to call the classes present, and by extension the functions within. The error is something I have never come ...
1
vote
2
answers
52
views
Why can't I use EXIT_SUCCESS instead of 0 in the return statement in Visual Studio Code?
Why can't I use EXIT_SUCCESS instead of 0 in the return statement in Visual Studio Code? I get the error:
id "EXIT_SUCCESS" is not defined
#include <stdio.h>
int main(void)
{
...
0
votes
0
answers
21
views
How can I solve this bug about NullPointerException [duplicate]
Good afternoon,
When I compile this code:
public class HelloWorld {
public static void main(String[] args) throws Exception {
AnimalFactory factory = new AnimalFactory();
System.out....
-4
votes
0
answers
55
views
Why below code gives compiler error :"main method not found in class a"? [duplicate]
import java.io.*;
class a{}
class b{
public static void main (String[] args) {
System.out.println("Geeks..");
}
}
If in above snippet,
I make class b as public, it gives ...
0
votes
0
answers
16
views
the standard deviation of the elements of a linked-representation queue
A method that finds the standard deviation of the elements of a linked-representation queue. What will be the implementation for this method?
-3
votes
2
answers
81
views
Return in C and C++ [duplicate]
So I have been coding in C for a while now, but one thing that still confuses me is the "return" at the end of functions.
Now I know that return is the value, which a function returns when ...
-1
votes
3
answers
45
views
Why is a static method called main launchable?
I guess there's something about jvm.BUT how does jvm recognize it?For the name main,or the static property?
That's my little confusion.
1
vote
0
answers
42
views
How to execute a file from another file with if __name__ == '__main__' for using multiprocessing
I am currently trying to parallelize a piece of code that trains a neural network with pytorch. For that I want to use the multiprocessing library. I now want to use a code ensemble of the following ...
1
vote
2
answers
50
views
Can i access a variable created in a main() function, in a separate class
Not quite sure how to word this, think i may be being stupid but i am declaring the variable albumInfoArray in my main() function. Is there a way to access this from my mainscreen class. For example ...
1
vote
1
answer
37
views
Is there a way to specify custom main.rs/lib.rs for Rust app development?
Perhaps use foo.rs/bar.rs instead of the default main/lib package root file?
How to config it?
0
votes
1
answer
37
views
How to make a UML diagram with a class that has a main method and no fields
I have a class that has a main() method and no fields and also it doesn't have a constructor. This class is just a simple class in a larger project, that I did it all by myself and that is why I feel ...
0
votes
0
answers
36
views
Runtime Error when running a LDA model of gensim on Windows
Okay, so i know this is a Windows error and not a Gensim error. Based on previous examples on the internet and other comments/solutions from Stack Overflow I came up with the code below. However, the ...
0
votes
0
answers
25
views
main process --> pthread --> fork --> lets the forked process run and kill main
Process A should start process B and then terminate. Process B should continue as an independent process
please have a little mercy on me - i am trying to educate myself and i like to learn more
int ...
4
votes
2
answers
82
views
Detect whether package is being run as a program within __init__.py
I have a Python package with an __init__.py that imports some things to be exposed as the package API.
# __init__.py
from .mymodule import MyClass
# ...
I also want to be able to use the package as ...
-1
votes
1
answer
32
views
find main class in java [closed]
Why java can't find my main?
this is my first java code
package MyPacage;
public class MyClass {
public static void main(string[] args) {
System.out.println("Hello world!");
}
}
3
votes
1
answer
110
views
Where is Haskell's or GHC's main defined?
In Haskell, the execution of a compiled program starts with executing main in module Main. This function must be of type IO ().
Which standard or reference defines the above?
Haskell 2010 and Haskell ...
23
votes
2
answers
1k
views
In Rust, what happens if main function returns Err?
According to The Rust Reference,
If a main function is present, (snip), and its return type must be one of the following:
()
Result<(), E> where E: Error
but it doesn't say what happens when ...
1
vote
2
answers
414
views
Go file not running which is not in main package
I have a very simple Go project setup.
At root directory I have go.mod file and main.go and a folder called main2. Inside main2 folder there is main2.go file.
/
|_ go.mod
|_ main.go
|_ main2
|_ ...
0
votes
1
answer
29
views
How to divide header and main, tags?
I just created a header, and after main section, and my main section is in header, I tried to margin from top, and isn't worked for me. I've made a screen, to show my problem :
I need to divide ...
0
votes
1
answer
237
views
Why is Program.cs no longer a class?
When you create a new application with the latest .NET Framework, Program.cs looks as follows:
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services....
3
votes
2
answers
106
views
Is it valid to use const char*[] as the type of second parameter of main
I am learning C++ and learnt that the following given declarations are equivalent:
int main (int argc, char *argv[]); //first declaration
int main (int argc, char **argv); //RE-DECLARATION. ...
0
votes
2
answers
32
views
How to call multiple functions in javascript and have them display?
I'm trying to call multiple functions at once and have them displayed on the screen. CalculateSum function is able to display correctly. The error message is quotient not defined. I've looked at ...
-7
votes
2
answers
100
views
What actually is int in int main void in c? [duplicate]
#include<stdio.h>
#include<conio.h>
int main(){
printf("hello world");
}
What actually does int do to the main function? Is it similar to the data type int? What does conio....
0
votes
1
answer
76
views
How do I retrieve data from an agent type and bring it to the main agent to set up experiments in AnyLogic?
I have developed a model that uses four agent types with state-chart and discrete events models simulating a team working behaviour.
As a logical step, I started by adding graphs and other analysis ...
0
votes
0
answers
6
views
Why does 'java -cp backend.jar Example' returns a ClassNotFoundException?
I know the manifest file looks strange with the path of "main.java...", but my Main class could not be found with a normal path (and neither with the current one)
Thanks for any advice in ...
0
votes
1
answer
442
views
Flutter Firebase has not been correctly initialized
I want to use firebase in my app,
I write this:
main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(Myapp());
}
but I got error :
I/ExoPlayerImpl( ...
-4
votes
1
answer
169
views
Should the "main function" (if __name__ == "__main__") have a type hint?
I understand that it is good practice to add a type hint to functions in my Python code. This helps when reading the code to clarify what type of value gets returned, and this metadata can also be ...
0
votes
0
answers
43
views
unable to compile application project on sdk 2019.1
I made hw design on vivado 2019.1 and i build application project on sdk 2019.1 based on .hdf file.
(My design consists of microblaze mcs)
i have 2 static libraries too .
When i try to compile main() ...
1
vote
1
answer
40
views
How to detect apostrophe in a char* argument?
I have a c file such that I pass arguments to as such:
./cfile [-size number]
e.g.
./cfile -size 22
Here is an example code for such a file:
int main(int argc, char** argv) {
if (argv[1] != &...
1
vote
2
answers
42
views
why does my main object, invoke all methods of another object, when only one is actually invoked?
Day 1 of learning scala :
This is my code, but I get unexpected results in one scenario.
object Hello extends App {
def square(x: Int) = x * x
println("Hello, World!")
}
object main ...
0
votes
2
answers
95
views
Why is `return` necessary in `match` arm when using `Result` in `main`?
I am reading Rust by Example book. In this example removing return in Err(e) => return Err(e) causes an error: expected `i32`, found enum `Result`` . Why is that?
What is the difference between Err(...
0
votes
1
answer
60
views
Expected type `Method` found enum `Result<_, MethodError>`
I am trying to convert a &str to an enum, but got the error Expected type Method found enum Result<_, MethodError> at this line Err(e) => Err(e). How to properly return an error in this ...
-1
votes
2
answers
132
views
Using command line parameters outside of main function [closed]
I would like a program to read in a file entered by the user via the command line, which is then used in the main body of the code.
See example code below:
#include <iostream>
#include <...
0
votes
1
answer
52
views
How to solve segmentation fault in change main function inputs with C code?
I want the following code, which is related to the Sysbench tool (https://github.com/akopytov/sysbench), to change from the following code to the next code, but I get an error with just this small ...
0
votes
1
answer
50
views
Vba Macro works but not starting in main()
Have created a Macro - multiple subs, functions and forms for Solidworks.
I'm sure the code is dubious but it works when I force it to start in main()
When I add a button in Solidworks to start the ...
0
votes
0
answers
34
views
main function to display output python
Hi I am doing a code and need to add a main function however I am having an issue adding this function as I dont know how to connect it to get the required output.
Can anyone offer some advice.
Each ...
1
vote
1
answer
75
views
What's the point of having a Main class in Python? [closed]
I have come across examples where people used a Main class, and from there, inside the Main class, write logic that instantiates other classes and calls their functions.
Example:
# ^^^ code containing ...
0
votes
1
answer
29
views
Using argparse scripts along with larger project
My objective is to use argparse command-line script along with a larger project. Especially I want to use some models from my project inside argparse_command.py.
Let's say the project structure is as ...
0
votes
2
answers
104
views
'InterfaceContainer' object has no attribute 'WethInterface'
from brownie import accounts, config, network, interface
def main():
"""
Runs the get_weth function to get WETH
"""
get_weth()
def get_weth(account=None):
""&...
7
votes
2
answers
110
views
How to get better error prompt if the input value from command line not in a list of valide choice in the MAIN routine?
Python's click module have choice-options, when the input is invalid:
import click
@click.command()
@click.option('--hash-type',
type=click.Choice(['MD5', 'SHA1'], case_sensitive=False))...