Questions tagged [main-method]
117 questions
0
votes
3 answers
In languages where you have a choice, is it better to put the main function/method/code at the top or bottom?
When you're writing a program that consists of a small bit of main logic that calls a bunch of supporting functions, you can choose either put the main logic at the top of the file or the bottom (Let's assume the language allows either.) Which is…

Ryan C. Thompson
- 40,856
- 28
- 97
- 159
0
votes
1 answer
Determining frame size and other calculations in a paging system
I just had the following question in an exam and was a bit lost with how to solve it. How would I go about making the requested calculations?
"A paging system uses 48-bit addresses, each of which specifies 1 byte (B) of memory. The system has a…

KOB
- 4,084
- 9
- 44
- 88
0
votes
1 answer
No main methods, applets, or MIDlets found
When I run this a popup comes up telling me no main methods, applets, or MIDlets ound. Can someone tell me why please?--I am using jGrasp. I am trying to use main method and I haven't had this issue before.
import java.util.*;
import…

Samuel Wyatt Cassady
- 19
- 2
0
votes
1 answer
error: illegal start expression. when placing a final string` statement in the `public static void main` method
I have just started learning Java a few weeks ago. I'm trying to learn the key word final in java language. I wrote a final string statement in the public static void main method. However, the IDE is displaying the error: illegal start expression.…

Thor
- 9,638
- 15
- 62
- 137
0
votes
2 answers
Why not call the static method "main" of a class from another class?
If I have a class:
public class HelloWorld {
public static String main(String[] args) throws IOException {
public createMessage(){
String message = "Hello World!";
}
}
return message; //return of the main static method
}
Why can't I…

ninjayoto
- 693
- 1
- 7
- 14
0
votes
6 answers
Main Method with int, Object and String [] args
I got the below code from internet and even though there are 3 main methods, if I run the app from command prompt:
java MainTest 1 2 3
I would get the output:
String main 1
public class MainTest {
public static void main(int [] args) {
…

Cuban coffee
- 294
- 5
- 14
0
votes
2 answers
How to associate an instance variable if all the code is inside a run() method?
I'm supposed to be creating a game, and we've been given free rein in creating it...but I have no idea what I'm doing. I copied the format of a previous lab, because I needed a way to run it, but now I have a problem. My Gui class is as…
user5495774
0
votes
1 answer
Error: Main Method exceeding bytes limit
I'm having an issue where I'm getting the error code:
Error: The code of method main(java.lang.String[]) is exceeding the 65535 bytes limit
while programming java.
I'm really quite new to java, and I don't really know what to do now.
I have…

Katrineeee
- 1
- 2
0
votes
3 answers
How can I refer to a variable under a static method in the main method?
My codes are like the following.
public class readfile {
public static void readfile() {
int i = 0;
System.out.println("hello");
}
public static void main(String[] args) {
readfile();
…

654170523
- 11
0
votes
1 answer
Writing a main method for this search function
I need some pointers as to how to write the main method for this mini-search engine I'm writing. Here is my code:
public class StringSearch {
private String s1 = "ACTGACGCAG";
private String s2 = "TCACAACGGG";
private String s3 =…

Tim Tolbert
- 7
- 3
0
votes
0 answers
Error:Main() method not found/ Running a spark code
I'm using spark-1.4.1, scala 2.10.5 and I code on eclipse IDE. I encounter the following error:
Error: Main() method not found
Cannot export the JAR file as it does not recognize the main class
How to start with writing a spark code?
import…

spark_dream
- 326
- 2
- 8
- 23
0
votes
4 answers
Main method is not static in class error
class useTent
{
Scanner keyboard=new Scanner (System.in);
public void main (String[] args)
{
Tent t= new Tent();
HireContract hc = new HireContract();
ProcessHire(t, hc);
}
}
this is my code, and i keep…

Emma Sproule
- 11
- 1
- 5
0
votes
1 answer
Getting Error : Exception in thread "main" while executing program for different loop conditions in static block
There is no problem in program execution if i am having loop condition as little value (i.e. 1000 or 10000) in static block, its working. the problem is in loop in static block for given code. whenever i am executing below code i am getting…

Prashant
- 2,556
- 2
- 20
- 26
0
votes
2 answers
Iterate through main function in C?
Here is my main function:
int main(int argc, char **argv)
{
LoadFile();
Node *temp;
char *key;
switch (GetUserInput())
{
case 1:
temp = malloc(sizeof(Node));
printf("\nEnter the key of the new node: ");
scanf("%s", temp->key);
…

Mohit Deshpande
- 53,877
- 76
- 193
- 251
0
votes
1 answer
How do you write a main method to start a java program?
I'm a beginner programmer and am tasked to write an inventory program.
I have only programmed using BlueJay so far, but am about to learn how to use the vim editor.
When programming with BlueJay, you didn't need to write a main method.
I'm so lost…

DaveMcFave
- 232
- 1
- 4
- 13