Help in understanding some code

I am new to java and need some help in understanding what the setHeapWithSize method does listed below. Thanks
public class HeapSort {
public void heapsort(int[] a){
          int [] A = setHeapWithSize(a, a.length);
          buildHeap(A);
          for (int i = a.length; i>1; i--){
               a[i-1] = A[0];
               A[0] = a[i-1];
               A=setHeapWithSize (A, A.length-1);
               heapify(a, 1);
               a[0] = A[0];
     public void buildHeap (int[] a) {
          for (int i = a.length/2; i>0; i--){
          heapify(a, i);
     public void heapify (int[] a, int i){
          int l = left(i);
          int r = right(i);
          int largest;
          if (l<= heapSize(a) && a[i-1]>a[i-1]){
          largest = l;
          else{
          largest=i;
          if (r<=heapSize(a) && a[r-1]> a[largest-1]){
          largest = r;
          if (largest != i){
          int tmp = a[i-1];
          a[i-1] = a[largest-1];
          a[largest-1] = tmp;
          heapify(a, largest);
     public int heapSize (int [] a){
     return a.length;
     public int parent (int i){
     return(i/2);
     public int left (int i){
     return (2*i);
     public int right (int i){
     return (2*i +1);
     }>

I am new to java and need some help in understanding
what the setHeapWithSize method does listed below.Don't you think it would be a smart move to show us the code for setHeapWithSize? Or do you want us to make a wild guess at what it does based on its name?

Similar Messages

  • Need help to change some code

    Hi Experts,
    I am new to Java and i struck up in some java code. could some one modify the code according to my requirement please..
    we hava a booking form contains the details like Destination ware house no, load number,PO number, line number.... When the supplier submit the form,Here we should reject the booking form .
    The booking form should reject in some cases where i have mentioned below. accordingly could some one modify the java code please..
    We have to reject such a booking form through the logic
    If Destination Warehouse = Different AND Load number = Common then
    “Reject the booking form”
    Else if
    Destination Warehouse = Different AND Load number = Different then
    "Pass the Booking form"
    Else If
    If Destination Warehouse = Common AND (Load number = Common OR Load number = Different)
    “Pass the booking form”
    Else
    it should Reject the form for different site on same load.
    The java code has been written like this. could someone modify it according to my requirement as i am new to Beginner to Java
    String[] vendor = new String[status.length];
    String[] load = new String[status.length]; //array of load numbers
    String[] site = new String[status.length]; // array of site (dest wh) numbers
    String[] temp = new String[20];
    String[] lstatus = status;
    String[] fail_loads = new String[status.length];
    String[] fail_sites = new String[status.length];
    MappingTrace trace = container.getTrace();
    trace.addInfo("No. of records: " + status.length);
    for(int i=0;i<status.length;i++){
    result.addValue(status);
    try{
    if (status.length != 1) {
    //Split input into Load Number and Vendor Number
    for (int i = 0; i < status.length; i++) {
    temp = status[i].split(":");
    load[i] = temp[1];
    site[i] = temp[5];
    if (temp[2].equals("9999999999")) vendor[i] = null;
    else vendor[i] = temp[2];
    temp = null;
    //Get Loads with two or more vendors
    String p_vendor = vendor[0];
    String p_load = load[0];
    String p_site = site[0];
    int idx = 0;
    int idxs = 0;
    trace.addInfo("Load Length: " + load.length);
    for (int i = 1; i < load.length; i++) {
    if (vendor[i] != null) {
    if (p_vendor != null && load[i].equals(p_load) && !load[i].equals("00")) { //same load as previous
    if (!vendor[i].equals(p_vendor)) { //second vendor in same load
    fail_loads[idx] = load[i];
    idx = idx + 1;
    if (!site[i].equals(p_site)) { //second site in same load
    fail_sites[idxs] = load[i];
    idxs = idxs + 1;
    p_load = load[i];
    p_vendor = vendor[i];
    p_site = site[i];
    trace.addInfo("For Loop 2: Index: " + i);
    trace.addInfo("fail Loads length: " + fail_loads.length);
    trace.addInfo("fail Sites length: " + fail_sites.length);
    //Set values in array Status[]
    for (int i = 0; i < status.length; i++) {
    for (int j = 0; j < fail_loads.length; j++)
    if (load[i].equals(fail_loads[j])) {
    //set status[i] to fail
    trace.addInfo("status[" + i + "] = " + status[i]);
    String msg = "fail" + status[i].substring(4);
    if (msg.length() <= 30)
    msg += ":999";
    status[i] = msg;
    trace.addInfo("status[" + i + "] = " + status[i]);
    break;
    for (int j = 0; j < fail_sites.length; j++)
    if (load[i].equals(fail_sites[j])) {
    //set status[i] to fail
    trace.addInfo("status[" + i + "] = " + status[i]);
    String msg = "fail" + status[i].substring(4);
    if (msg.length() <= 30)
    msg += ":998";
    status[i] = msg;
    trace.addInfo("status[" + i + "] = " + status[i]);
    break;
    result.addValue(status[i]);
    }// end for i
    }//endif
    else
    result.addValue(status[0]);
    }//end try
    catch (Exception e)
    StringWriter stringWritter = new StringWriter();
    PrintWriter printWritter = new PrintWriter(stringWritter, true);
    e.printStackTrace(printWritter);
    String error = "Exception: "
    + stringWritter.toString();
    trace.addInfo("This is exception: " + e.getStackTrace());
    Thanks,
    Suesh

    990094 wrote:
    I am new to Java and i struck up in some java code. could some one modify the code according to my requirement please..No. Ask for help so YOU can change it and learn from it, don't flat out ask other people to do it for you. People will just assume you'll be the one flipping their burgers in the future if you do that.
    new to JavaThere is a forum that has this exact name, I suggest you take your further questions (not requests to outsource work) there.

  • Trying To Understand Some Code Which Uses the [i] Syntax

    Ok I'm trying to get a grip on using loops within flex and I found the following code somewhere which utilises a for in loop. It basically is a function that creates several labels for all of the elements in an object. One thing I cannot understand is what the [i] is used for on line 5 i.e. (myArray[i])  or more specifically what the purpose of such Square brackets in situations like these are used for. Does it refer to looking for all Strings in the array (as defined on line 3) as I assume it does? It's just pretty confusing. Can anyone point me to a guide on the syntax of square brackets and what they mean or help me out? with an explanation? Cheers.
    private function createLabels():void{
    var myArray:Array = ['one', "two", 3];
    for(var i:String in myArray){
    var myLabel:Label = new Label();
    myLabel.text = (myArray[i]);
    myBox.addChild(myLabel);

    You've probably already seen these, but here are a couple of links that may help.
    http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/operators.html#array_a ccess
    http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/Array.html
    What's basically happening is that the "for" loop goes through each item in the array.  Don't be confused by the fact that two of the items in the array are Strings and one is an Integer - variable i being a String has nothing to do with the data type of the elements in the array.
    The following code:
    private function createLabels():void
         var myArray:Array = ['one', 'two', 3];
         for(var i:String in myArray)
              trace("i = " + i);
              trace(myArray[i]);
    gives the following results:
    i = 0
    one
    i = 1
    two
    i = 2
    3
    From that we can see that the "for" loop is assigning the index number of each array element, not the actual array element ('one', 'two', or 3) to the variable i.  So calling myArray[i] is the same as calling myArray[0] the first time through the loop.  This type of "for" loop is just a shorter way of doing the following, which produces exactly the same results:
    private function createLabels():void
         var myArray:Array = ['one', 'two', 3];
         for(var i:int = 0; n < myArray.length; i++)
              trace("i = " + i);
              trace(myArray[i]);
    Hope that helps.
    Cheers!

  • Help with understand this code

    hi,
    i wont to now what doing this code i now that performed extraction but to
    where?
    LOOP AT work_days.
          CLEAR p0001.
          PROVIDE * FROM p0001
           BETWEEN work_days-date AND work_days-date.
          ENDPROVIDE .
          PROVIDE * FROM p0315
           BETWEEN work_days-date AND work_days-date.
          ENDPROVIDE .
          IF sy-subrc <> 0 .
            CLEAR p0315-accnt .
          ENDIF .
    endloop.
    Regards

    hi
    any suggstion?
    regards

  • Helping to understand a c++ code

    Hello everybody.
    I have a problem with an example provided by NI for DAQmx ANSI C programmation. I putted this question here, because I could not find a suitable board for it.
    About the problem: I'm currently working with a NI PCI-6120 device and therefore I like to connect a trigger signal to PFIO and a AI channel at which the software should acquire data in combination with a trigger event (->PFIO). Serveral times.
    I found a good example (http://zone.ni.com/devzone/cda/tut/p/id/5382) which should do the things I'd like to have, but I have problems to understand the code or maybe I don't really understand the way they realized it.
    Here the code:
    #include <string.h>
    #include <stdio.h>
    #include <NIDAQmx.h>
    static TaskHandle  AItaskHandle=0,DItaskHandle=0;
    #define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
    static int32 GetTerminalNameWithDevPrefix(TaskHandle taskHandle, const char terminalName[], char triggerName[]);
    int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData);
    int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
    int main(void)
     int32   error=0;
     char    errBuff[2048]={'\0'};
     char    trigName[256];
     // DAQmx Configure Code
     DAQmxErrChk (DAQmxCreateTask("",&AItaskHandle));
     DAQmxErrChk (DAQmxCreateAIVoltageChan(AItaskHandle,"Dev1/ai0",​"",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volt​s,NULL));
     DAQmxErrChk (DAQmxCfgSampClkTiming(AItaskHandle,"",10000.0,DAQ​mx_Val_Rising,DAQmx_Val_ContSamps,1000));
     DAQmxErrChk (GetTerminalNameWithDevPrefix(AItaskHandle,"ai/Sam​pleClock",trigName));
     DAQmxErrChk (DAQmxCreateTask("",&DItaskHandle));
     DAQmxErrChk (DAQmxCreateDIChan(DItaskHandle,"Dev1/port0","",DA​Qmx_Val_ChanForAllLines));
     DAQmxErrChk (DAQmxCfgSampClkTiming(DItaskHandle,trigName,10000​.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
     DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(AItaskHandle,DAQm​x_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,N​ULL));
     DAQmxErrChk (DAQmxRegisterDoneEvent(AItaskHandle,0,DoneCallbac​k,NULL));
     // DAQmx Start Code
     DAQmxErrChk (DAQmxStartTask(DItaskHandle));
     DAQmxErrChk (DAQmxStartTask(AItaskHandle));
     printf("Acquiring samples continuously. Press Enter to interrupt\n");
     printf("\nRead:\tAI\tDI\tTotal:\tAI\tDI\n");
     getchar();
    Error:
     if( DAQmxFailed(error) )
      DAQmxGetExtendedErrorInfo(errBuff,2048);
     if( AItaskHandle ) {
      // DAQmx Stop Code
      DAQmxStopTask(AItaskHandle);
      DAQmxClearTask(AItaskHandle);
      AItaskHandle = 0;
     if( DItaskHandle ) {
      // DAQmx Stop Code
      DAQmxStopTask(DItaskHandle);
      DAQmxClearTask(DItaskHandle);
      DItaskHandle = 0;
     if( DAQmxFailed(error) )
      printf("DAQmx Error: %s\n",errBuff);
     printf("End of program, press Enter key to quit\n");
     getchar();
     return 0;
    static int32 GetTerminalNameWithDevPrefix(TaskHandle taskHandle, const char terminalName[], char triggerName[])
     int32 error=0;
     char device[256];
     int32 productCategory;
     uInt32 numDevices,i=1;
     DAQmxErrChk (DAQmxGetTaskNumDevices(taskHandle,&numDevices));
     while( i<=numDevices ) {
      DAQmxErrChk (DAQmxGetNthTaskDevice(taskHandle,i++,device,256))​;
      DAQmxErrChk (DAQmxGetDevProductCategory(device,&productCategor​y));
      if( productCategory!=DAQmx_Val_CSeriesModule && productCategory!=DAQmx_Val_SCXIModule ) {
       *triggerName++ = '/';
       strcat(strcat(strcpy(triggerName,device),"/"),t​erminalName);
       break;
    Error:
     return error;
    int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
     int32       error=0;
     char        errBuff[2048]={'\0'};
     static int  totalAI=0,totalDI=0;
     int32       readAI,readDI;
     float64     AIdata[1000];
     uInt32      DIdata[1000];
     // DAQmx Read Code
     DAQmxErrChk (DAQmxReadAnalogF64(AItaskHandle,1000,10.0,DAQmx_V​al_GroupByChannel,AIdata,1000,&readAI,NULL));
     DAQmxErrChk (DAQmxReadDigitalU32(DItaskHandle,1000,10.0,DAQmx_​Val_GroupByChannel,DIdata,1000,&readDI,NULL));
     printf("\t%d\t%d\t\t%d\t%d\r",readAI,readDI,total​AI+=readAI,totalDI+=readDI);
     fflush(stdout);
    Error:
     if( DAQmxFailed(error) ) {
      DAQmxGetExtendedErrorInfo(errBuff,2048);
      // DAQmx Stop Code
      if( AItaskHandle ) {
       DAQmxStopTask(AItaskHandle);
       DAQmxClearTask(AItaskHandle);
       AItaskHandle = 0;
      if( DItaskHandle ) {
       DAQmxStopTask(DItaskHandle);
       DAQmxClearTask(DItaskHandle);
       DItaskHandle = 0;
      printf("DAQmx Error: %s\n",errBuff);
     return 0;
    int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData)
     int32   error=0;
     char    errBuff[2048]={'\0'};
     // Check to see if an error stopped the task.
     DAQmxErrChk (status);
    Error:
     if( DAQmxFailed(error) ) {
      DAQmxGetExtendedErrorInfo(errBuff,2048);
      DAQmxClearTask(taskHandle);
      if( DItaskHandle ) {
       DAQmxStopTask(DItaskHandle);
       DAQmxClearTask(DItaskHandle);
       DItaskHandle = 0;
      printf("DAQmx Error: %s\n",errBuff);
     return 0;
    Here my questions:
    1: DAQmxErrChk (GetTerminalNameWithDevPrefix(AItaskHandle,"ai/Sam​pleClock",trigName));
    I don't get this. Why don't they just put one specific channel name at var: trigName?
    2.1: DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(AItaskHandle,DAQm​x_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,N​ULL));
    2.2: DAQmxErrChk (DAQmxRegisterDoneEvent(AItaskHandle,0,DoneCallbac​k,NULL));
    Why do they setup the event on the AI channel? I thought I have to check for events on the trigger channel?!
    3: int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
    Does this event occur for every N samples acquired?
    In summary I don't understand how the program is realising the 'wait on trigger' and then starts to acquire the data. In my eyes they just plot the data on both channels without any trigger.
    Thank you for reading that far. Maybe someone can help me to understand it correctly!
    Bye
    Denis

    Hello,
    it is me again. I modified the code you provided to me. So far I can say it is working =)
    But there are some things I like to know and maybe you can explain it to me.
    Right now my code acquires data from two channels. I removed the BufferInput-function, because he was not able to trigger or run corretly if I have serveral scans/triggers.
    Questions:
    Why does it run if I dont use a specific InputBufferSize?
    // ---------------------------------------- code snippet ----------------------------------------------
    // ChanSR - SampleRate
    // ChanSmpPts - SamplesPerChan
    // Channels = \Dev3\ai0:1 (2 channels)
    // -- create Tasks
    DAQmxErrChk (DAQmxCreateTask("", &AItaskHandle));
    DAQmxErrChk (DAQmxCreateTask("", &COtaskHandle));
    // -- create voltage chan, configure timing and optional the buffer size   
    DAQmxErrChk (DAQmxCreateAIVoltageChan(AItaskHandle, Channels, "", DAQmx_Val_Cfg_Default, -ChanVolts, ChanVolts, DAQmx_Val_Volts, NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(AItaskHandle, "Ctr0InternalOutput", ChanSR, DAQmx_Val_Falling, DAQmx_Val_ContSamps, (int32) ChanSmpPts));
    //DAQmxErrChk (DAQmxSetBufferAttribute (AItaskHandle, DAQmx_Buf_Input_BufSize, ChanSmpPts*2));
    // -- create the clock for the acquistion
    DAQmxErrChk (DAQmxCreateCOPulseChanFreq (COtaskHandle, "Dev3/ctr0", "", DAQmx_Val_Hz, DAQmx_Val_Low, 0., ChanSR, 0.5));
    DAQmxErrChk (DAQmxCfgImplicitTiming (COtaskHandle, DAQmx_Val_FiniteSamps, ChanSmpPts));
    // -- create trigger and define the edge        
    DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(COtaskHandle,"PFI0", DAQmx_Val_Rising));    
    DAQmxErrChk (DAQmxSetTrigAttribute (COtaskHandle, DAQmx_StartTrig_Retriggerable, TRUE));       
    // -- start the tasks
    DAQmxErrChk (DAQmxStartTask(COtaskHandle));
    DAQmxErrChk (DAQmxStartTask(AItaskHandle));
    // -- knowing the numbers of triggers we repeat the acquisition
    for(i=0; i<TrigEvents; i++)
        DAQmxErrChk (DAQmxReadAnalogF64(AItaskHandle, (int32) ChanSmpPts, 2.0, DAQmx_Val_GroupByChannel, buffer, 
                                          (int32) (ChanCount * ChanSmpPts), &read, NULL));       
        for(k = 0; k < len; k++) 
             result[k + i*len] = buffer[k]; // just plot/save the data
    Cleanup();
    Bye
    Denis

  • Help in understanding the MouseRotate Source code.(Source code attached)

    Hi
    I am trying to understand the code here in the class below. The description says MouseTranslate is a Java3D behavior object that lets users control the
    translation (X, Y) of an object via a mouse drag motion with the third mouse button (alt-click on PC). See MouseRotate for similar usage info I was able to locate the isAltDown() and isMetaDown conditions. But could not figure out where is the condition (evt.getButton() == MouseEvent.Button1) is being checked.
    I have spent too much time on this, any help is greatly appreciated.
    Thanking you
    Venkat
    package com.sun.j3d.utils.behaviors.mouse;
    * MouseTranslate is a Java3D behavior object that lets users control the
    * translation (X, Y) of an object via a mouse drag motion with the third
    * mouse button (alt-click on PC). See MouseRotate for similar usage info.
    public class MouseTranslate extends MouseBehavior {
        double x_factor = .02;
        double y_factor = .02;
        Vector3d translation = new Vector3d();
        private MouseBehaviorCallback callback = null;
         * Creates a mouse translate behavior given the transform group.
         * @param transformGroup The transformGroup to operate on.
        public MouseTranslate(TransformGroup transformGroup) {
         super(transformGroup);
         * Creates a default translate behavior.
        public MouseTranslate(){
         super(0);
         * Creates a translate behavior.
         * Note that this behavior still needs a transform
         * group to work on (use setTransformGroup(tg)) and
         * the transform group must add this behavior.
         * @param flags
        public MouseTranslate(int flags) {
         super(flags);
         * Creates a translate behavior that uses AWT listeners and behavior
         * posts rather than WakeupOnAWTEvent.  The behavior is added to the
         * specified Component. A null component can be passed to specify
         * the behavior should use listeners.  Components can then be added
         * to the behavior with the addListener(Component c) method.
         * @param c The Component to add the MouseListener
         * and MouseMotionListener to.
         * @since Java 3D 1.2.1
        public MouseTranslate(Component c) {
         super(c, 0);
         * Creates a translate behavior that uses AWT listeners and behavior
         * posts rather than WakeupOnAWTEvent.  The behaviors is added to
         * the specified Component and works on the given TransformGroup.
         * A null component can be passed to specify the behavior should use
         * listeners.  Components can then be added to the behavior with the
         * addListener(Component c) method.
         * @param c The Component to add the MouseListener and
         * MouseMotionListener to.
         * @param transformGroup The TransformGroup to operate on.
         * @since Java 3D 1.2.1
        public MouseTranslate(Component c, TransformGroup transformGroup) {
         super(c, transformGroup);
         * Creates a translate behavior that uses AWT listeners and behavior
         * posts rather than WakeupOnAWTEvent.  The behavior is added to the
         * specified Component.  A null component can be passed to specify
         * the behavior should use listeners.  Components can then be added to
         * the behavior with the addListener(Component c) method.
         * Note that this behavior still needs a transform
         * group to work on (use setTransformGroup(tg)) and the transform
         * group must add this behavior.
         * @param flags interesting flags (wakeup conditions).
         * @since Java 3D 1.2.1
        public MouseTranslate(Component c, int flags) {
         super(c, flags);
        }Rest of the code follows in the next post

        public void initialize() {
         super.initialize();
         if ((flags & INVERT_INPUT) == INVERT_INPUT) {
             invert = true;
             x_factor *= -1;
             y_factor *= -1;
         * Return the x-axis movement multipler.
        public double getXFactor() {
         return x_factor;
         * Return the y-axis movement multipler.
        public double getYFactor() {
         return y_factor;
         * Set the x-axis amd y-axis movement multipler with factor.
        public void setFactor( double factor) {
         x_factor = y_factor = factor;
         * Set the x-axis amd y-axis movement multipler with xFactor and yFactor
         * respectively.
        public void setFactor( double xFactor, double yFactor) {
         x_factor = xFactor;
         y_factor = yFactor;   
        public void processStimulus (Enumeration criteria) {
         WakeupCriterion wakeup;
         AWTEvent[] events;
         MouseEvent evt;
    //      int id;
    //      int dx, dy;
         while (criteria.hasMoreElements()) {
             wakeup = (WakeupCriterion) criteria.nextElement();
             if (wakeup instanceof WakeupOnAWTEvent) {
              events = ((WakeupOnAWTEvent)wakeup).getAWTEvent();
              if (events.length > 0) {
                  evt = (MouseEvent) events[events.length-1];
                  doProcess(evt);
             else if (wakeup instanceof WakeupOnBehaviorPost) {
              while (true) {
                  // access to the queue must be synchronized
                  synchronized (mouseq) {
                   if (mouseq.isEmpty()) break;
                   evt = (MouseEvent)mouseq.remove(0);
                   // consolodate MOUSE_DRAG events
                   while ((evt.getID() == MouseEvent.MOUSE_DRAGGED) &&
                          !mouseq.isEmpty() &&
                          (((MouseEvent)mouseq.get(0)).getID() ==
                        MouseEvent.MOUSE_DRAGGED)) {
                       evt = (MouseEvent)mouseq.remove(0);
                  doProcess(evt);
         wakeupOn(mouseCriterion);
        void doProcess(MouseEvent evt) {
         int id;
         int dx, dy;
         processMouseEvent(evt);
         if (((buttonPress)&&((flags & MANUAL_WAKEUP) == 0)) ||
             ((wakeUp)&&((flags & MANUAL_WAKEUP) != 0))){
             id = evt.getID();
    *         if ((id == MouseEvent.MOUSE_DRAGGED) && !evt.isAltDown() && evt.isMetaDown()) { *
              x = evt.getX();
              y = evt.getY();
              dx = x - x_last;
              dy = y - y_last;
              if ((!reset) && ((Math.abs(dy) < 50) && (Math.abs(dx) < 50))) {
                  //System.out.println("dx " + dx + " dy " + dy);
                  transformGroup.getTransform(currXform);
                  translation.x = dx*x_factor;
                  translation.y = -dy*y_factor;
                  transformX.set(translation);
                  if (invert) {
                   currXform.mul(currXform, transformX);
                  } else {
                   currXform.mul(transformX, currXform);
                  transformGroup.setTransform(currXform);
                  transformChanged( currXform );
                  if (callback!=null)
                   callback.transformChanged( MouseBehaviorCallback.TRANSLATE,
                                     currXform );
              else {
                  reset = false;
              x_last = x;
              y_last = y;
             else if (id == MouseEvent.MOUSE_PRESSED) {
              x_last = evt.getX();
              y_last = evt.getY();
         * Users can overload this method  which is called every time
         * the Behavior updates the transform
         * Default implementation does nothing
        public void transformChanged( Transform3D transform ) {
         * The transformChanged method in the callback class will
         * be called every time the transform is updated
        public void setupCallback( MouseBehaviorCallback callback ) {
         this.callback = callback;
    }

  • Help with understanding multi-threaded code

    Hi Everyone,
    I am currently reading a book on multi-threading and up until recently I have been able to understand what is going on. The thing is the complexity of the code has just jumped up about two gears without warning. The code is now using inner classes which I am trying to develop an understanding of but I am not finding it easy going, and the book has been lite on explanations. If anybody can help with the following code it will be really appreciated.
    public class SetPriority extends Object
         private static Runnable makeRunnable()
              Runnable r = new Runnable()
                   public void run()
                        for(int i=0; i<5; i++)
                             Thread t = Thread.currentThread();
                             System.out.println("in run() - priority=" + t.getPriority() +
                                          ", name=" + t.getName());
                             try{
                                  Thread.sleep(2000);
                             }catch(InterruptedException x){
                                  //ignore
              return r;
         public static void main(String[] args)
              Thread threadA = new Thread(makeRunnable(), "threadA");
              threadA.setPriority(8);
              threadA.start();
              Thread threadB = new Thread(makeRunnable(), "threadB");
              threadB.setPriority(2);
              threadB.start();
              Runnable r = new Runnable()
                   public void run()
                        Thread threadC = new Thread(makeRunnable(), "threadC");
                        threadC.start();
              Thread threadD = new Thread(r, "threadD");
              threadD.setPriority(7);
              threadD.start();
              try{
                   Thread.sleep(3000);
              }catch(InterruptedException x){
                   //ignore
              threadA.setPriority(3);
              System.out.println("in main() - threadA.getPriority()=" + threadA.getPriority());
    }My greatest challenge is understanding how the makeRunnable() method works. I don't understand how this inner class can be declared static and then multiple "instances" created from it. I know that I have no idea what is going on, please help!!!
    Thanks for your time.
    Regards
    Davo
    P.S.: If you know of any really good references on inner classes, particularly URL resources, please let me know. Thanks again.

    Yikes!! The good news is that you're unlikely to see such convoluted code in real life. But here we go.
    "private static Runnable makeRunnable()" declares a method that returns objects of type Runnable. The fact that the method is declared "static" is pretty irrelevant - I'll describe what that means later.
    The body of the method creates and returns an object of type Runnable. Not much special about it, except that you can give such an object to the constructor of class Thread and as a result the run() method of this Runnable object will be called on a new thread of execution (think - in parallel).
    Now the way it creates this Runnable object is by using the "anonymous inner class" syntax. In effect the method is doing the same as
    public class MyNewClass implements Runnable {
        public void run() {
            // All the same code inside run()
    public class SetPriority {
        private static Runnable makeRunnable() {
            Runnable r = new MyNewClass();
            return r;
        // The rest of the original code
    }Except you don't bother declaring MyNewClass. You're not interested in defining any new method signatures. You just want to create an object that implements Runnable and has certain instructions that you want inside the run() method. Think of the whole approach as shorthand.
    Think about this for a while. In the mean time I'll write up the "static".

  • Hello congratulations for the work you have been developing. The iCREATE has helped me greatly improve my Mac and better understand some applications. Recently my iPhoto has given me problems and I do not realize what is happening. When I double click a p

    Hello congratulations for the work you have been developing. The apple support has helped me greatly improve my Mac and better understand some applications. Recently my iPhoto has given me problems and I do not realize what is happening. When I double click a photo it does not appear ... or rather the background is black and only the zoom window appears. How to solve this? I've done a restoration of the library, but the problem remains. Thanks and good job.

    There are several possible causes for the Black Screen issue
    1. Permissions in the Library: Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Include the option to check and repair permissions.
    2. Minor Database corruption: Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild.
    3. A Damaged Photo: Select one of the affected photos in the iPhoto Window and right click on it. From the resulting menu select 'Show File (or 'Show Original File' if that's available). (On iPhoto 11 this option is under the File -> Reveal in Finder.) Will the file open in Preview? If not then the file is damaged. Time to restore from your back up.
    4. A corrupted iPhoto Cache: Trash the com.apple.iPhoto folder from HD/Users/Your Name/Library/ Caches...
    5. A corrupted preference file: Trash the com.apple.iPhoto.plist file from the HD/Users/ Your Name / library / preferences folder. (Remember you'll need to reset your User options afterwards. These include minor settings like the window colour and so on. Note: If you've moved your library you'll need to point iPhoto at it again.)
    If none of these help:
    As a Test:
    Hold down the option (or alt) key key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?

  • Need help in Understanding synchronization through code

    I read someone that synchronization is suppose to allow only one thread to access a synchronized method or block of code. But then I wrote some code just to test it out.
    import java.util.ArrayList;
    import java.util.Vector;
    public class Testing extends Thread {
         private String someString;
         static Vector<Integer> someVec;
         static ArrayList<Integer> someArrayList;
         public Testing(String value) {
              someString = value;
              someVec = new Vector<Integer>();
              someArrayList = new ArrayList<Integer>();
         public static void main(String args[]) {
              Testing one = new Testing("one");
              Testing two = new Testing("two");
              one.start();
              two.start();
         public void run() {
              if (someString.equals("one")) {
                   for (int i = 0; i < 1000; i++) {
                        try {
                             someVec.add(i);
                        } catch (RuntimeException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                        System.out.println("adding with " + i);
              } else
                   for (int i = 0; i < someVec.size(); i++)
                        try {
                             System.out.println("getting .. " + someVec.get(i)+ " from "+someVec.size());
                        } catch (RuntimeException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
    }Now my questions
    1. Why the 2nd thread is able to access the someVec ( Vector) when the 1st thread is still adding some values?
    2. When I changed someVec to someArrayList the result is still the same. I wonder why ?
    3. Lastly, Can anyone modify my code so only either a Vector or a Arraylist will make the program run without error ? Because right now I can run them both fine, so I don't see the difference.
    Thank you.
    Regards,
    Mustafa

    Vrijmetse wrote:
    1. Why the 2nd thread is able to access the someVec ( Vector) when the 1st thread is still adding some values?You have not added any synchronization around your Vector operations. Vector's individual methods are synchronized, but that only extends to the execution of those methods. There's no way for that syncing to know that you're doing stuff in a for loop. If you want to complete the for loop without anything else affecting that Vector, then you need a sync block around the body of the loop, and anything else that acceses the Vector must also sync on the same object. The Vector itself is a good candidate for the lock here.
    (There may be other problems as well. I haven't read your code closely. Just noticed the for loop and lack of syncing.)
    2. When I changed someVec to someArrayList the result is still the same. I wonder why ?Same reason.
    3. Lastly, Can anyone modify my code so only either a Vector or a Arraylist will make the program run without error ?No.

  • Can someone help me with this code?

    Hi all,
    I have a Flash component that links to a gallery, and I
    understand that I can create buttons to point to multiple
    galleries. (waiting too long for support from the suppliers)
    The User Guide says that I can use the following to create
    the connection:
    myThumbnailer2.loadGallery(24);
    That won't work, and it says that I need to include it in an
    onclipevent. I have no idea what i am doing and I was hoping
    someone could tell me what to script to get the text button I
    created to run this.
    Help would really be appreciated.
    Hugh

    Hi Hugh,
    You are right in that you can link to other galleries using
    the ID number (but, I assume, only TN2Admin (fCMSPro gallery
    document) defined galleries) with the code supplied.
    I think this may help - I'm a newbie with actionscript and I
    know nothing about Flashloaded so I may be way off beam here,
    but....
    First define a variable, this will be used in the 'show'
    (that's show, not load) gallery element of your code:
    var galNum: Number;
    Make as many buttons as required to launch a gallery (you say
    "each button opening one of several galleries" so I assume you want
    1 gallery per button) and give each an instance name.
    You then write the relevant code for each button function
    (assuming once more that the buttons are in the same frame) using
    the instance name (I use a separate layer in the frame to write
    actionscript and try not to attach code directly to objects - which
    then leads me to say yes you can put all the different buttons code
    in one frame)....
    myLoadGalBtn1.onRelease = function () {
    myThumbnailer2.loadGallery(24);
    galNum = 24;
    myLoadGalBtn2.onRelease = function () {
    myThumbnailer2.loadGallery(25);
    galNum = 25;
    notice the buttons have different instance names (the 1 &
    2 at the end - but you can call them what you like).
    Then you can use other code supplied to actually show the
    gallery (using the variable generated in each button click). Some
    code from Flashloaded will be along the lines of:
    myThumbnailer2.showGallery(25);
    so my guess is you can replace the actual number with the
    variable galNum inside the brackets to use the number generated by
    whatever button was pressed, like:
    myThumbnailer2.showGallery(galNum);
    Cheers
    Kol

  • Can anyone help me understand "Continue Statements"?

    Hi,
    I was wondering if anyone could help me understand continue statements. I've been studying the java tutorials this weekend but can not get my head around the following explanation: (My thoughts are at the end of this message and it might be easiest to read them first!)
    "The continue statement skips the current iteration of a for, while , or do-while loop. The unlabeled form skips to the end of the innermost loop's body and evaluates the boolean expression that controls the loop. The following program, ContinueDemo , steps through a String, counting the occurences of the letter "p". If the current character is not a p, the continue statement skips the rest of the loop and proceeds to the next character. If it is a "p", the program increments the letter count.
    {code}class ContinueDemo {
    public static void main(String[] args) {
    String searchMe = "peter piper picked a peck of pickled peppers";
    int max = searchMe.length();
    int numPs = 0;
    for (int i = 0; i < max; i++) {
    //interested only in p's
    if (searchMe.charAt(i) != 'p')
    continue;
    //process p's
    numPs++;
    System.out.println("Found " + numPs + " p's in the string.");
    }{code}
    Here is the output of this program:
    Found 9 p's in the string.
    To see this effect more clearly, try removing the continue statement and recompiling. When you run the program again, the count will be wrong, saying that it found 35 p's instead of 9.
    A labeled continue statement skips the current iteration of an outer loop marked with the given label. The following example program, ContinueWithLabelDemo, uses nested loops to search for a substring within another string. Two nested loops are required: one to iterate over the substring and one to iterate over the string being searched. The following program, ContinueWithLabelDemo, uses the labeled form of continue to skip an iteration in the outer loop.
    {code}class ContinueWithLabelDemo {
    public static void main(String[] args) {
    String searchMe = "Look for a substring in me";
    String substring = "sub";
    boolean foundIt = false;
    int max = searchMe.length() - substring.length();
    test:
    for (int i = 0; i <= max; i++) {
    int n = substring.length();
    int j = i;
    int k = 0;
    while (n-- != 0) {
    if (searchMe.charAt(j++)
    != substring.charAt(k++)) {
    continue test;
    foundIt = true;
    break test;
    System.out.println(foundIt ? "Found it" :
    "Didn't find it");
    }{code}
    Here is the output from this program.
    Found it"
    Here are Woodie's thoughts........................................
    1) With the first program I don't understand how the program counts the number of "p's". Like for example how it stores the number of "p's". Shouldn't it say:
    if (searchMe.charAt(i) = 'p') then store it in some sort of containers??? 2) With the second program, I don't understand the test section. For example: Why does it have --? why does it have != after while and why does it have != after if?
    while (n-- != 0)
                    if (searchMe.charAt(j++) != substring.charAt(k++))
                        continue test;
                foundIt = true;
                     break test;Edited by: woodie_woodpeck on Nov 23, 2008 3:29 AM

    Woodie, I think they're just silly "theoretical" examples... ergo don't worry too much not understanding them, coz they don't actually make a lot of sense... as you've allready pointed out there are other "more normal" control structures which achieve the same thing, and which in this case (in my humble opinion) would make for clearer, more concise, more maintainable code.
    All you need to know about continue is "it means go back to the top of the loop"... If you're not comfortable using "continue" then don't.
    There's more than one way to do it.
      public static void main(String[] args) {
        try {
          final String s = "peter piper picked a peck of pickled peppers";
          int count = 0;
          for ( char c : s.toStringArray() ) {
            if (c=='p') count++;
          System.out.println("There are "+count+ " p's in '"+s+"'");
        } catch (Exception e) {
          e.printStackTrace();
      }Having said all that... I did use continue in anger the other day... I was reading Geometries from a shape file... the reader was throwing an ArrayIndexOutOfBoundsException given an "empty Feature" (ie a feature with the geospatial presence)... All I did was catch the exception and continue trying to read the new feature... the alternative would have been to rewrite the control logic of the whole reader loop... quick, simple effective... but I don't routinely build continue statements into new code... just a matter of personal taste.
    Cheers. Keith.

  • Help needed understanding final keyword and  use 3

    Hi Everyone,
    I have been studying a book on multi-threading and have inadvertently come accross some code that I don't really understand. I am wondering if anybody can explain to me the following:
    1). What effect does using the final keyword have when instantiating objects, and
    2). How is it possible to instantiate an object from an interface?
    public class BothInMethod extends Object
         private String objID;
         public BothInMethod(String objID)
              this.objID = objID;
         public void doStuff(int val)
              print("entering doStuff()");
              int num = val * 2 + objID.length();
              print("in doStuff() - local variable num=" + num);
              // slow things down to make observations
              try{
                   Thread.sleep(2000);
              }catch(InterruptedException x){}
              print("leaving doStuff()");
         public void print(String msg)
              String threadName = Thread.currentThread().getName();
              System.out.println(threadName + ": " + msg);
         public static void main(String[] args)
              final BothInMethod bim = new BothInMethod("obj1");  //Use of final on objects?
              Runnable runA = new Runnable()      //Creating objects from an interface?
                   public void run()
                        bim.doStuff(3);
              Thread threadA = new Thread(runA, "threadA");
              threadA.start();
              try{
                   Thread.sleep(200);
              }catch(InterruptedException x){}
              Runnable runB = new Runnable()
                   public void run()
                        bim.doStuff(7);
              Thread threadB = new Thread(runB, "threadB");
              threadB.start();
    }If you know of any good tutorials that explain this (preferably URL's) then please let me know. Thanks heaps for your help.
    Regards
    Davo

    final BothInMethod bim = new BothInMethod("obj1");  //Use of final on objects?
    Runnable runA = new Runnable()      //Creating objects from an interface?          
         public void run()               
                                    bim.doStuff(3);               
    };Here final is the characteristics of bim reference variable and it is not the characteristics of class BothInMethod
    This means u cannot use bim to point to some other object of the same class
    i.e, u cannot do this
                       final BothInMethod bim = new BothInMethod("obj1"); 
                       bim  =  new   BothInMethod("obj2");  This bim is a constant reference variable which will point only to the object which it is initialized to
    and not to any other object of the same class later on.
    How is it possible to instantiate an object from an interface?Regarding this yes we cannot create an object from an interface but
    but here it is not an interface u are providing the implementation of the interface Runnable
    as
    new Runnable()
    }This now no longer stays an interface but now it is an object that implements the interface Runnable

  • Help fix my java code!

    I am a java student in high school, and im attempting to create a program to figure how many items i can buy without going over a set price. I do not have all the equations in yet (i need to figure them out).... but can u help me fix my code please!!! More than likely all of my errors are from being new at java programming.... but please help lol! (if at all possible, i need to stay in the javax.swing and not any other import declarations)
    if i need to explain what im doing anywhere, just reply and say u don't understand it or something.
    import javax.swing.*;
    class SmeltingConversion
    public static void main(String args[])
      int amount, equation, coal_qty, iron_qty, coal_price, iron_price, gold_qty, iron_input, gold_input, coal_input, mythreal_input, mythreal_qty, adament_input, adament_qty, rune_input, rune_qty, select;
      JOptionPane.showMessageDialog(null, "Created by:\n\tFinalFntsy3\n\nCopyright 2006", "Smelting Conversions", JOptionPane.PLAIN_MESSAGE);
      select = JOptionPane.showInputDialog("Please type one of the following numbers: 1(Bronze), 2(Iron), 3(Steel), 4(Mythreal), 5(Adament), 6(Rune).");
       switch(select)
       case 1:
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         tin_input = JOptionPane.showInputDialog("Please enter the price per piece of tin.");
         copper_input = JOptionPane.showInputDialog("Please enter the price per piece of copper."); 
         gold_qty=Integer.parseInt(gold_input);
         tin_qty=Integer.parseInt(tin_input);
         copper_qty=Integer.parseInt(copper_input);
         equation = gold_qty/(tin_price + copper_price);
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Bronze Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
       case 2:
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         coal_input = JOptionPane.showInputDialog("Please enter the price per piece of coal ore.");
         iron_input = JOptionPane.showInputDialog("Please enter the price per piece of iron ore."); 
         gold_qty=Integer.parseInt(gold_input);
         coal_qty=Integer.parseInt(coal_input);
         iron_qty=Integer.parseInt(iron_input);
         equation = gold_qty/(iron_price + (2*coal_price));
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Steel Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
       case 3:
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         coal_input = JOptionPane.showInputDialog("Please enter the price per piece of coal ore.");
         mythreal_input = JOptionPane.showInputDialog("Please enter the price per piece of mythreal ore."); 
         gold_qty=Integer.parseInt(gold_input);
         coal_qty=Integer.parseInt(coal_input);
         mythreal_qty=Integer.parseInt(mythreal_input);
         equation = gold_qty/(tin_qty + copper_qty);
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Mythreal Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
       case 4:
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         coal_input = JOptionPane.showInputDialog("Please enter the price per piece of coal ore.");
         adament_input = JOptionPane.showInputDialog("Please enter the price per piece of adament ore."); 
         gold_qty=Integer.parseInt(a_input);
         coal_qty=Integer.parseInt(coal_input);
         adament_qty=Integer.parseInt(adament_input);
         equation = gold_qty/(tin_qty + copper_qty);
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Adament Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
       case 5:
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         coal_input = JOptionPane.showInputDialog("Please enter the price per piece of coal ore.");
         rune_input = JOptionPane.showInputDialog("Please enter the price per piece of rune ore."); 
         gold_qty=Integer.parseInt(a_input);
         coal_qty=Integer.parseInt(coal_input);
         rune_qty=Integer.parseInt(rune_input);
         equation = gold_qty/(tin_qty + copper_qty);
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Rune Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
      JOptionPane.showMessageDialog(null, "Total amount of coal needed:\n \t" + a + "\nTotal amount of iron needed:\n \t", "Smelting Conversions", JOptionPane.PLAIN_MESSAGE);
    }

    There are a lot of things to fix within your Program.
    Why don't you try to fix your compiler errors by yourself before you ask others to do it for you ?
    JOptionPane.showInputDialog returns a String and that can't be convertet to an int without parsing the String.
    Some variables ar simply not declared and so on.
    I've tried to fix the first switich case for you so you can see how it could possibly look like
    int  coal_qty, iron_qty, coal_price, iron_price, gold_qty, iron_input, coal_input, mythreal_input, mythreal_qty, adament_input, adament_qty, rune_input, rune_qty;
      int selectId;
      String select ;
      double amount = 0.0;
      double equation;
      JOptionPane.showMessageDialog(null, "Created by:\n\tFinalFntsy3\n\nCopyright 2006", "Smelting Conversions", JOptionPane.PLAIN_MESSAGE);
      select = JOptionPane.showInputDialog("Please type one of the following numbers: 1(Bronze), 2(Iron), 3(Steel), 4(Mythreal), 5(Adament), 6(Rune).");
      selectId = Integer.parseInt(select);
    switch(selectId)
       case 1:
           String gold_input;
           String tin_input;
           String copper_input;
           double tin_price = 1.0;
           double copper_price = 1.0;
         gold_input = JOptionPane.showInputDialog("Please enter the amount of gold available");
         tin_input = JOptionPane.showInputDialog("Please enter the price per piece of tin.");
         copper_input = JOptionPane.showInputDialog("Please enter the price per piece of copper."); 
         tin_price = Double.parseDouble(tin_input);
         copper_price = Double.parseDouble(copper_input);
         gold_qty=Integer.parseInt(gold_input);
         equation = gold_qty/(tin_price + copper_price);
         equation = amount;
         JOptionPane.showMessageDialog(null, " ", "Bronze Conversion", JOptionPane.INFORMATION_MESSAGE);
         break;
       }

  • Error Posting IDOC: need help in understanding the following error

    Hi ALL
    Can you please, help me understand the following error encountered while the message was trying to post a IDOC.
    where SAP_050 is the RFC destination created to post IDOCs
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Call Adapter
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>XIAdapter</SAP:Category>
      <SAP:Code area="IDOC_ADAPTER">ATTRIBUTE_IDOC_RUNTIME</SAP:Code>
      <SAP:P1>FM NLS_GET_LANGU_CP_TAB: Could not determine code page with SAP_050 Operation successfully executed FM NLS_GET_LANGU_CP_TAB</SAP:P1>
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Error: FM NLS_GET_LANGU_CP_TAB: Could not determine code page with SAP_050 Operation successfully executed FM NLS_GET_LANGU_CP_TAB</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Your help is greatly appreciated.............Thank you!

    Hi Patrick,
      Check the authorizations assigned to the user which you used in the RFC destinations, If there is no enough authorizations then it is not possible to post the idocs.
    Also Refer this Note 747322
    Regards,
    Prakash

  • Can you help me understand the use of the word POSITION in TR and CFM?

    Hi,
    I am trying to have a view of typical BI reports in TR and TM/CFM so through my research I came to the following link:.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/62/08193c38f98e1ce10000000a11405a/frameset.htm
    My problem on this link and other postings on this site seem to be the same. Can you help me understand the use of the word POSITIONS in these context:
    1. Our client has asked for financial transaction reports in BW, such as position of Borrowings, Investments and Hedge Operations (TM data).
    2. I have a requirement on, some reports related to Money Market (Fixed Term Deposits, Deposits at Notice) something on FSCM-Treasury and Risk Manager. These reports will be similar to that of Loans, i.e. Position statement, flow statement, etc.
    3. The set of position values for a single position or a limited amount of positions can be reported by transactions TPM12 and TPM13 in R3.
    4. 0CFM_C10 (Financial Positions Cube)
    Do you have some simple report outputs to help clarify how the word POSITION is used in such environments?
    Thanks
    Edited by: AmandaBaah on Feb 15, 2010 4:39 PM

    If I future buy 10 shares in company at £1 per share - at the end of the day my potential value is £10
    The next day the shares drop tp £0.9 per share - I have a negative position - my shares are only worth £9
    I haven;t bought them yet - but I have a negative position - ie if things stayed as they are - I am going to realise (ie end up with)  a loss
    Now you can use this for loans and foreign exchange banks as well...

Maybe you are looking for

  • Embedding Fonts Into A PDF

    Hi There, I'm having trouble sending my files to the printers, my fonts is jumping... How do i make sure that my fonts are embedded into my PDF file, I'm using indesign cs5.5 Please can someone help me, I have distiller as well. Thank You Kind Regard

  • Problem with showing focus points in 3.5.1 & 10.9

    I cannot always display the focus points either by using Option + F or View > Show Focus Points on my MBP, late 2012. Prior to 3.5.1 & 10.9, either one of these commands would always display or remove, the focus points. At times I can restore the foc

  • "UNLIMITED TABLESPACE" is revoked - don't know who did that

    I got call from developer they encountered error from insert statement stating ERROR at line 1: ORA-01536: space quota exceeded for tablespace 'XXXXXXXX' I went there and found that "unlimited tablespace" is revoked from that user. I can not explain

  • Lightroom v1.0 Install Leaves Read-Only Files in Temp Directory

    I just installed v1.0 (fresh install, no previous betas, WinXP). There seem to be quite a few (20 to be exact) read-only files left in the folder: C:\Documents and Settings\**User**\Local Settings\Temp\ These all appear to be related to Sonic Solutio

  • EHP1 upgrade error in PREP_INPUT..phase

    Hello, I am doing EHP1 upgrade and getting error in EHPI during the PREP_INPUT/KX_CPYORG! phase. Below is the error: Severe error(s) occured in phase PREP_INPUT/KX_CPYORG! Last error code set: Cannot open '/usr/sap/<SID>/SYS/exe/run/dbatoolsora.lst':