Blog of Maxim Pedich

Home page

How to start, restart, stop MySQL on MacOS from terminal

Jun 8, 2016, 12:53

Start
sudo /usr/local/mysql/support-files/mysql.server start

Stop
sudo /usr/local/mysql/support-files/mysql.server stop

Restart
sudo /usr/local/mysql/support-files/mysql.server restart

How to run 2 skype accounts at the same time on mac os

May 31, 2016, 16:06

Use next command from terminal:

sudo /Applications/Skype.app/Contents/MacOS/Skype

List of practical project

Apr 17, 2016, 4:56

There is the list of practical project for those who want programming more and more.

https://github.com/karan/Projects

Removing element from list

May 14, 2014, 15:51

What is the result of this code?

List<Integer> integers = new ArrayList<Integer>();
integers.add(1);
integers.add(2);
integers.add(3);
integers.add(4);
integers.add(5);
for (Integer integer : integers) {
   if (integer % 2 == 0) {
      integers.remove(integer);
   }
}

When does the finally block not execute?

Apr 5, 2013, 20:37
try {
    System.exit(0);
} finally {
    System.out.println("finally");
}

Exceptions in Java

Apr 2, 2013, 15:11

What is the result of this code?

Task 1.

public static void m() {
try {
    throw new Exception();
} catch (Exception e) {
    System.out.println("catch");
} finally {
    System.out.println("finally");
}

Task 2.

int i = 0;
try {
    throw new Exception();
} catch (Exception e) {
    i = 10;
    return i;
} finally {
    i = 20;
}

Task 3.

int i = 0;
try {
    throw new Exception();
} catch (Exception e) {
    i = 10;
    return i;
} finally {
    i = 20;
    return i;
}

Array and println() method

Apr 1, 2013, 16:44

What is the result of this code?

char[] charArr = { 'W', 'o', 'r', 'l', 'd' };
System.out.println("char[]" + charArr);
System.out.println(charArr);
int[] intArr = { 1, 2, 3, 4, 5 };
System.out.println(intArr.toString());

Why this code will be return java.lang.Error?

Mar 27, 2013, 12:19
public class Test{
    public static void main(String[] args) {
	int і = 10;
	System.out.println(i);
    }
}
 

HashMap in Java

Mar 25, 2013, 18:31
import java.util.HashMap;
import java.util.Map;
 
public class HashMapTest {
    public static void main(String[] args) {
	Person p1 = new Person(20);
	Person p2 = new Person(20);
 
	Map<Person, Person> m = new HashMap<Person, Person>();
	m.put(p1, p2);
	m.put(p2, p1);
	System.out.println(m.size());
    }
}
 
class Person {
    private int age;
 
    public Person(int age) {
	this.age = age;
    }
 
    @Override
    public int hashCode() {
	return age;
    }
}