Praveen Palaniswamy

Greenhorn
+ Follow
since Feb 09, 2011
Praveen likes ...
Mac OS X Java Ubuntu
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Praveen Palaniswamy

# public static MidiEvent makeEvent(int comd, int chan, int one, int two, int tick){
# MidiEvent event = null; // ???
# try {
# ShortMessage a = new ShortMessage();
# a.setMessage(comd, chan, one, two); <-- this could thrown an exception so in that case
# event = new MidiEvent(a, tick);
#
# } catch (Exception e) {
# }
# return event; <-- what am i trying to return?
# }

the method is marked to return a object of type MidiEvent so any class that calls this method will expect some thing in return either a event or null ;
since the try block allows the option to throw exceptions, we might end up in the return statement with event not pointing to anything so this causes the compile error.
13 years ago
1. class child {
2. int y = 12;
3. public void testIt() {
4. System.out.println("x is blank");
5.
6. // parent p = new parent();
7. //System.out.println("x in parent is " + p.x);
8. }
9. }
10.
11. class testProtect {
12. public void testAccess() {
13. int cx = child.y; <-- whats child here 1 doesn't get related to 2 either pass the reference of 1 or declare the variable as static
14. System.out.println("x is " + cx);
15. }
16. }
17.
18. public class Main {
19. public static void main(String[] args) {
20. child childob = new child(); <-- you define new child object 1
21. childob.testIt();
22. testProtect tp = new testProtect(); <-- new test project here 2
23. tp.testAccess();
24. }
25.
26. }
13 years ago
int a = (Integer) null;

throws a null pointer exception. Is this documented in javadoc? also if any one could point out why is it not assigned 0 which will be the default for an int.
13 years ago