Skip to content

Instantly share code, notes, and snippets.

View martinomburajr's full-sized avatar
🦆
Relentlessly pursuing those carbs

Martin Ombura Jr. martinomburajr

🦆
Relentlessly pursuing those carbs
View GitHub Profile
public static void main(String []args) {
//your work here!
}
public class FunMainMethodTrivia {
//Original Main Method
//JVM will always call it
public static void main(String []args) {
//
}
//Valid overload
//JVM will not call it.
public static void main(String s1) {
//You must call this method as a developer
/**
* Retrieved from https://developer.android.com/reference/android/os/Looper.html
*/
class LooperThread extends Thread {
public Handler mHandler;
public void run() {
Looper.prepare();
mHandler = new Handler() {
public void handleMessage(Message msg) {
// process incoming messages here
@martinomburajr
martinomburajr / medium-android-activity-thread-main-method.java
Last active December 15, 2017 17:40
The Activity Threads main method
/**
* Code retrieved from https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/ActivityThread.java
* Modifications are indicated in the comments
*/
public static void main(String[] args) {
//Modification - Removed unrelated initializers.
//Android initializes some tracers, event loggers, enviroment initializers, trusted certificates and updates the process' state
Looper.prepareMainLooper();
ActivityThread thread = new ActivityThread();
thread.attach(false);
/**
* AOSP
* Looper class
*/
public static void loop() {
final Looper me = myLooper();
if (me == null) {
throw new RuntimeException("No Looper; Looper.prepare() wasn't called on this thread.");
}
final MessageQueue queue = me.mQueue;
@martinomburajr
martinomburajr / medium-main-method-d.d
Created December 7, 2017 11:39
D programming language main method
void main();
void main(string[] args);
int main();
int main(string[] args);
@martinomburajr
martinomburajr / medium-main-method-go.go
Created December 7, 2017 11:41
Go Programming Language - Main Method
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
@martinomburajr
martinomburajr / medium-main-method-haskell.hs
Created December 7, 2017 11:42
Haskell Programming Language main method
main :: IO()
main =
putStrLn "Hello, World!"
@martinomburajr
martinomburajr / medium-main-method-pike.pike
Created December 7, 2017 11:44
Pike Programming Language - Main Method
int main() {
write("Hello world!\n");
return 0;
}
@martinomburajr
martinomburajr / medium-main-method-python.py
Created December 7, 2017 11:46
Python Programming Language - Main Method
import sys
def main(argv):
n = int(argv[1])
print(n + 1)
if __name__ == '__main__':
sys.exit(main(sys.argv))