Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Focusing

S. M. AMRAN smamran

:octocat:
Focusing
View GitHub Profile
@smamran
smamran / ThisKeyWord.Java
Created Aug 21, 2015
Usage of This keyword..
View ThisKeyWord.Java
package com.netcse.java;
public class Main {
int id;
String name;
Main(int i, String n){
id = i;
name = n;
@smamran
smamran / ChartView.java
Created Aug 25, 2015
Simple Shadow Chart View
View ChartView.java
/**
* Created by Google on 8/22/2015.
*/
package com.example.google.interview;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@smamran
smamran / SynchronizedThreadJoin.java
Created Sep 15, 2015
Java Thread with Synchronized Thread Join
View SynchronizedThreadJoin.java
class Worker {
private static long count = 0;
public synchronized void increment() {
for (int i = 0; i < 10; i++) {
count++;
}
}
@smamran
smamran / ThreadLockObject.java
Created Sep 15, 2015
Thread With Lock Object
View ThreadLockObject.java
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
class App {
public static void main(String[] args) {
Worker worker = new Worker();
worker.main();
@smamran
smamran / OsAndArchitect.java
Created Sep 20, 2015
Operating System and Architecture detection i java code.
View OsAndArchitect.java
package com.netcse.java;
public class Main {
private static final String OS_NAME = System.getProperty("os.name").toString();
public static void main(String[] args) {
System.out.println("Hello world java programming in this world is nothing but java");
System.out.println(OS_NAME);
System.out.println(System.getProperty("os.arch").toString());
@smamran
smamran / StackTraceCheck.java
Last active Sep 20, 2015
Stack Tracing for a function.
View StackTraceCheck.java
package com.netcse.java;
public class Main {
public static void main(String[] args) {
StackTraceElement[] stackTraceElement = Thread.currentThread().getStackTrace();
for (StackTraceElement s : stackTraceElement) {
System.out.println(s.toString());
}
@smamran
smamran / ExitFXGUI.java
Created Sep 20, 2015
Exit FX Stage or Scene by Pressing Esc Key
View ExitFXGUI.java
primaryStage.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>(){
@Override
public void handle(KeyEvent event) {
if(event.getCode() == KeyCode.ESCAPE){
primaryStage.close();
}
}
@smamran
smamran / ExitJFrameGUI.java
Created Sep 20, 2015
Exit Focused JFrame by Pressing Esc Key
View ExitJFrameGUI.java
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Cancel");
getRootPane().getActionMap().put("Cancel", new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
@smamran
smamran / GenericsVsNonGen.java
Last active Sep 20, 2015
Generics vs Non Generics Java
View GenericsVsNonGen.java
// The following code snippet without generics requires casting:
List list = new ArrayList();
list.add("hello");
String s = (String) list.get(0);
// When re-written to use generics, the code does not require casting:
List<String> list = new ArrayList<String>();
list.add("hello");
String s = list.get(0); // no cast
@smamran
smamran / TodoTask.md
Created Sep 20, 2015
Todo Task Reading Watching Doing