Top.Mail.Ru
April 4th, 2005 - Java developers — LiveJournal
? ?

Java developers

April 4th, 2005

08:29 am - theycallmesir - Interfaces as callbacks

I'm reading through O'Reilly's Learning Java and I'm having trouble wrapping my brain around this concept. Here's the example code they give.

interface TextUpdateable {
  void doTextUpdate( String text);
}

class TickerTape implements TextUpdateable {
  public void doTextUpdate(String text) {
     System.out.println("TICKER:\n" + text + "\n");
  }
}

class TextSource {
  TextUpdateable receiver;
  TextSource(TextUpdateable r) {
     receiver = r;
  }

  public void sendText( String s) {
     receiver.doTextUpdate(s);
  }
}


I understand the basic concept of Interfaces, specifying defined behavior through a group of abstract classes.
Can someone explain to me what's going on here?

10:05 am - icehockeyangel - let me try again.

Ok well I'm having problems getting input from a keyboard.
it wont stop. it wont do anything. I've put it away looked at it again. got even more confused.

Code Can Be Found Here <--not a lj cut.. linkage...

my teacher wants us to use a do while loop for most of it. and that also confuzes me.
can anyone point me in the right direction?
please and thank you
<3

01:55 pm - sparkymark - JNI signature of inner class?

I have a class Clazz that can be initialised by passing in static fields of itself...

public class Clazz {
   public final static Inner MY_TRUE = new Inner();
   public final static Inner MY_FALSE = new Inner();
   public Clazz(Inner x) { ... }
   private static class Inner {}
}

So from Java I can initialise an instance of Clazz with Clazz(Clazz.MY_TRUE) without the caller needing access to the name of the inner class.

Is it possible to create an object of Clazz from JNI? Does the JNI code need to know the signature of the "" methods (i.e. constructor), and if so what is it ( "Clazz$Inner" ?) and is it accessible via an arbitrary JNI call ( i.e. not from a native method of Clazz)?

resolved: javap -p -s pointed me to the solution
Powered by LiveJournal.com