Writing a small code in HANA

Hi,
I am interested in HANA ..I am totally new to this side ..
I read all papers on HANA .Theoretically I know HANA mostly but wants to taste by practically .
Please can somebody tell me the steps to write a small code on this ??
What tool is required...whether tool is free ...how can I use this tool ...
Please do the needful and guide me .
-Ashwini

Hi Aswinin,
You can get 30 days free HANA trail . There you can try the theory part you learned .. Welcome to HANA , Enjoy it
scn.sap.com/docs/DOC-28191
Sreehari

Similar Messages

  • How to write BW extractor code in HANA

    Dear All,
    We are writing calculation view in HANA from analyzing logic of BW extractor.
    Can it is possible to write BW code in HANA in ABAP perspective to minimize the effort.
    Regards,
    Amol

    Lars,
    Actually we are spending more time to generating logic from BW ABAP extractor to creation of HANA views.
    Actually I am asking for Help...

  • What this small code does? And how do I do it in Unicode.

    Hi.
    I got the following code and I really don't know what it does or even why. All I know It's not UC enabled ( since it's uxinf the type x).
    I was thinking I might be converting from ascii representation to text or something like that but I'm not that sure.
    FORM TRANSLATE_FIELD USING    STRING_TRAN
                         CHANGING STRING1.
      DATA: STRING(255),
             len1(3) type i,
             LEN(3)  TYPE I,
             NUM(3)  TYPE I,
             I(3)    TYPE I.
      DATA: C VALUE 'A',
            X TYPE X.
      FIELD-SYMBOLS:<fc> type c.
      STRING = STRING_TRAN.
      len1 = strlen( STRING ).
      LEN = 0.
      NUM = 0.
      while len < len1.
        i = STRING+len(3).
        move i to x.
        assign x to <fc> casting type c.
        move <fc> to c.
        MOVE C TO STRING1+NUM.
        len = len + 3.
        NUM = NUM + 1.
      endwhile.
    ENDFORM.                    " TRANSLATE_FIELD
    Thanks
    Ariel

    Hi.
    I want to make this small code UC enabled. Since there is a move of TYPE x into char this is not OK at the mopment.
    the problem is I don't really know or understand how to convert itr to UC enabled program.
    You can notice it takes clusters of 3 chars (bytes ?) long and convert them to char.
    For example 101 = e 100 = d 099 = c.... :-> 101099101 -> ece .
    Thanks
    Ariel

  • How to create multi node /data Tree by using few loops or small code

    HI.
    I WANT TO CREATE A TREE WHICH IS HAVING MULTI NUMBER OF NODE LEVEL (USER HAVE THE ABILITY TO CREATE AS MANY AS REQUIRED NODE LEVEL OR SUBLEVEL). HOW CAN I POPULATE THE TREE WITH SMALL CODE. AS EVERY NODE LEVEL NEED ON NESTED LOOP. SO HOW CAN I MANAGE TO POPULATE THE NODE WITH FEW LOOPS. OR THERE IS ANY OTHER WAY TO MANAGE THIS PROBLEM.
    THANKS

    Hi ,
    I am trying to do the job , but i do not understand where
    is the problem with my loop , i am sending it , could you
    see it , and sujjest me , what to do. or if you have time
    can you write the code for me. as i am very much needy for
    this job.
    The Table is as:-
    CREATE TABLE TREE_01(
    RECORD_NO NUMBER(10), --
    OWN_CODE VARCHAR2(10),
    PARENT_NO NUMBER(10),
    PARENT_CODE VARCHAR2(10),
    LEVELL NUMBER(4),
    DEPT NUMBER(6),
    CONSTRAINT RNO_PK PRIMARY KEY(RECORD_NO));
    INSERT INTO TREE_01 VALUES(1,'1',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(2,'2',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(3,'3',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(4,'4',0,'0',2,8540);
    INSERT INTO TREE_01 VALUES(5,'1',1,'0',3,8540);
    INSERT INTO TREE_01 VALUES(6,'2',1,'0',3,8540);
    INSERT INTO TREE_01 VALUES(7,'3',1,'0',3,8540);
    INSERT INTO TREE_01 VALUES(8,'1',3,'0',3,8540);
    INSERT INTO TREE_01 VALUES(9,'2',3,'0',3,8540);
    the loop shoud look like
    |_DataProcessing
    | |+Work_orders
    | |_Programmers File
    | | |_James
    | | | |+Requests
    | | | |+Leves
    | | | |_Projects
    | | | |_Projects001
    | | |+Steven
    |+HealthCare
    |+Transportation
    So the loop should be such that it can be go to any level of any node.
    the Code i writter is As follows.
    The Following Procedure is called in form leve
    When new forms instance.
    PROCEDURE REFRESH_TREE2 IS
    CURSOR CUR_DEPT IS
         SELECT DEPT
         FROM TREE_01 GROUP BY DEPT;
    CURSOR CUR_LOOP1(PARENT1 NUMBER,LEVEL1 NUMBER) IS
         SELECT RECORD_NO,
         OWN_CODE,
         PARENT_NO,
         DEPT ,
         PARENT_CODE,
         LEVELL
         FROM TREE_01
         WHERE LEVELL=LEVEL1
         AND RECORD_NO=PARENT1;
    CURSOR CUR_LOOP2(PARENT2 NUMBER,LEVEL2 NUMBER) IS
         SELECT RECORD_NO,
         OWN_CODE,
         PARENT_NO,
         DEPT ,
         PARENT_CODE,
         LEVELL
         FROM TREE_01
         WHERE LEVELL=LEVEL2
         AND RECORD_NO=PARENT2;
    CURSOR LEVEL(PARENTNO NUMBER) IS
         SELECT LEVELL FROM TREE_01 WHERE PARENT_NO=PARENTNO
         ORDER BY RECORD_NO;
         V_I NUMBER;
         V_IGNORE NUMBER;
         RG_DEPT RECORDGROUP;
         RG_CABI RECORDGROUP;
         V_INIT_STATE GROUPCOLUMN;
         V_LEVEL GROUPCOLUMN;
         V_LABEL GROUPCOLUMN;
         V_ICON GROUPCOLUMN;
         V_VALUE GROUPCOLUMN;
         V_CHANGE_VALUE VARCHAR2(20);
         V_CHANGE_VALUE1 NUMBER(3);
         V_CHANGE_VALUE2 NUMBER(3);
    V_LEVEL_COUNT NUMBER;
    BEGIN
         SELECT MAX(LEVELL) INTO V_LEVEL_COUNT FROM TREE_01;
         RG_DEPT:=FIND_GROUP('DEPT');
         if not id_null(RG_DEPT) then
    delete_group(RG_DEPT);
    end if;
         RG_DEPT:=create_group('DEPT');
         V_INIT_STATE := add_group_column(RG_DEPT, 'INIT_STATE', NUMBER_COLUMN);
         V_LEVEL :=ADD_GROUP_COLUMN(RG_DEPT,'LEVEL',NUMBER_COLUMN);
         V_LABEL :=ADD_GROUP_COLUMN(RG_DEPT,'LABEL',CHAR_COLUMN,40);
         V_ICON :=ADD_GROUP_COLUMN(RG_DEPT,'ICON',CHAR_COLUMN,20);
         V_VALUE :=ADD_GROUP_COLUMN(RG_DEPT,'VALUE',CHAR_COLUMN,15);
         V_I :=1;
         FOR DEPTREC IN CUR_DEPT LOOP
         ADD_GROUP_ROW(RG_DEPT,V_I);
         SET_GROUP_NUMBER_CELL(V_INIT_STATE,V_I,1);
         SET_GROUP_NUMBER_CELL(V_LEVEL ,V_I,1);
         SET_GROUP_CHAR_CELL(V_LABEL ,V_I,FILING.ELOOK_IT(11,0,DEPTREC.DEPT));--MAIN_MINOR));
         SET_GROUP_CHAR_CELL(V_ICON ,V_I,NULL);
         SET_GROUP_CHAR_CELL(V_VALUE ,V_I,TO_CHAR(DEPTREC.DEPT)); --MAIN_MINOR));
         V_I:= V_I +1;
         V_CHANGE_VALUE := DEPTREC.DEPT;
         FOR I IN 1..V_LEVEL_COUNT LOOP
         FOR DEPTREC1 IN CUR_LOOP1(V_CHANGE_VALUE,I) LOOP --MAIN_MINOR,I) LOOP
         ADD_GROUP_ROW(RG_DEPT,V_I);
         SET_GROUP_NUMBER_CELL(V_INIT_STATE,V_I,1);
         SET_GROUP_NUMBER_CELL(V_LEVEL ,V_I,I);
         SET_GROUP_CHAR_CELL(V_LABEL ,V_I,DEPTREC1.RECORD_NO);
         SET_GROUP_CHAR_CELL(V_ICON ,V_I,NULL);
         SET_GROUP_CHAR_CELL(V_VALUE ,V_I,DEPTREC1.RECORD_NO);
         V_I:= V_I +1;
         SELECT count(LEVELL) INTO V_CHANGE_VALUE1
    FROM TREE_01
    WHERE RECORD_NO=DEPTREC1.RECORD_NO
         AND PARENT_NO=DEPTREC1.PARENT_NO
         AND LEVELL=DEPTREC1.LEVELL;
         SELECT MAX(LEVELL) INTO V_CHANGE_VALUE2
         FROM TREE_01
         WHERE RECORD_NO=DEPTREC1.RECORD_NO
         AND PARENT_NO=DEPTREC1.PARENT_NO
         AND LEVELL=DEPTREC1.LEVELL;
              FOR j IN 1..V_CHANGE_VALUE1 loop
              FOR LVL IN LEVEL(DEPTREC1.RECORD_NO) LOOP
              FOR DEPTREC2 IN CUR_LOOP2(DEPTREC1.RECORD_NO, LVL.LEVELL) LOOP
         ADD_GROUP_ROW(RG_DEPT,V_I);
         SET_GROUP_NUMBER_CELL(V_INIT_STATE,V_I,1);
         SET_GROUP_NUMBER_CELL(V_LEVEL ,V_I,LVL.LEVELL);
         SET_GROUP_CHAR_CELL(V_LABEL ,V_I,DEPTREC2.RECORD_NO);
         SET_GROUP_CHAR_CELL(V_ICON ,V_I,NULL);
         SET_GROUP_CHAR_CELL(V_VALUE ,V_I,DEPTREC2.RECORD_NO);
         V_I:= V_I +1;
         V_CHANGE_VALUE := DEPTREC2.RECORD_NO;
                   end loop;
         end loop;
         END LOOP;
         END LOOP;
         END LOOP;
         END LOOP;
         ftree.set_tree_property('NAVIGATOR.NAV_DISPLAY',ftree.record_Group, rg_dept);
         end;

  • Need help in writing a small java code

    Hi,
    I have a small requirement where I need write a small java code. I am thinking of using array. Please suggest if you know the solution:
    1. Need to compare user logon id is preset in the lookup table or not.
    2. If user id present in the lookup then send type "A" mail
    3. If user id in not present in the lookup then send type "B" email.
    Please suggest.
    Thanks,
    Kalpana.

    use this code . you have to pass userlogin and lookup name
    Public String GetEmail(String UserLogin,String lookupcode)
    String email;
    try{
    tcLookupOperationIntf lookupIntf = Platform.getService(tcLookupOperationIntf.class);
    HashMap<String, String> lookupValues = getLookupHashMap(lookupIntf, lookupCode);
    String found = lookupValues.get(UserLogin);
    if (found!=null) email= "EMAIL A";
    else
    email= "EMAIL B";
    }catch(Exception e){}
    return email;
    private HashMap<String, String> getLookupHashMap(tcLookupOperationsIntf lookupOperationsIntf, String lookupCode)throws tcAPIException,tcInvalidLookupException,tcColumnNotFoundException {
    HashMap<String, String> lookupMap = new HashMap<String, String>();
              tcResultSet resultLookupHashMap = lookupOperationsIntf
                        .getLookupValues(lookupCode);
              int countResultLookupHashMap = resultLookupHashMap.getRowCount();
    if (countResultLookupHashMap > 0) {
                   for (int i = 0; i < countResultLookupHashMap; i++) {
                        resultLookupHashMap.goToRow(i);
                        lookupMap.put(resultLookupHashMap..getStringValue("Lookup Definition.Lookup Code Information.Code Key"),
    resultLookupHashMap.getStringValue("Lookup Definition.Lookup Code Information.Decode"));
    return lookupMap;
    }

  • Help needed in writing a small piece of ABAP Code

    Subject : look up in an ODS and update in a characteristic routine (BI 7.0)  
    Hi ,
    My requirement is : I have data coming from both legacy as well as SAP Systems. The user wants both legacy as well as SAP fields data in their reports.
    I have a Standard DSO ( say DSO1) with all the legacy fields with direct mappings from Legacy sytem along with couple of SAP fields which are not mapped as of now.
    I have few more DSO's which have just the legacy field and corresponding SAP field data.
    like DSO 2 with ZCOMPCODE and 0COMPCODE data.
    All i have to do is write a Routine for unmapped 0COMPCODE field in DSO1 that pulls up corrersponding 0COMPCODE values for ZCOMPCODE from DSO 2 .
    *Could someone please help me with the Coding part of the Routine.*
    Greatly appreciate your help.

    CREATE OR REPLACE FUNCTION fucntion_name(latA IN NUMBER, longA IN NUMBER, latB IN NUMBER, longB IN NUMBER) RETURN NUMBER
    IS
    pi      CONSTANT NUMBER:=3.14159;
    theta NUMBER;
    distX  NUMBER;
    distY  NUMBER;
    distZ  NUMBER;
    distP  NUMBER;
    BEGIN
    theta :=longA - longB;
    distX :=sin( latA * PI /180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180);
    distY :=acos(distX); --this is arc cosine
    distZ :=distY * 180/PI;  --PI refers to the mathematical PI
    distP :=distZ * 60 * 1.1515; --this value should be returned. Of course the intermediate variable names don't matter.
    RETURN distP;
    END;Edited by: Ora on May 3, 2011 11:46 PM

  • Small code correction

    I am new in Java, I need help for small correction of applet code(I'm not confident how to make this correctly)- I need clean a popup banner at applet loading. The about part , which appears by click on 'about' button, can be left without changes, it does not prevent me.
    Part of a code containing a popup:
    import a.*;
    import java.applet.Applet;
    import java.applet.AppletContext;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.*;
    public final class dbView extends Applet
    implements Runnable, ActionListener, o, ItemListener
    public void stop()
    if(A != null)
    A.dispose();
    if(t != null)
    t.dispose();
    private void _mthvoid()
    B = a.i.a(getClass(), "Begin.gif");
    e = a.i.a(getClass(), "Right.gif");
    z = a.i.a(getClass(), "Left.gif");
    u = a.i.a(getClass(), "End.gif");
    b = a.i.a(getClass(), "Redo.gif");
    J = a.i.a(getClass(), "Binocular.gif");
    m = a.i.a(getClass(), "Home.gif");
    MediaTracker mediatracker = new MediaTracker(this);
    mediatracker.addImage(B, 0);
    mediatracker.addImage(e, 0);
    mediatracker.addImage(z, 0);
    mediatracker.addImage(u, 0);
    mediatracker.addImage(b, 0);
    mediatracker.addImage(J, 0);
    mediatracker.addImage(m, 0);
    try
    mediatracker.waitForAll();
    catch(InterruptedException interruptedexception) { }
    private int _mthdo(String s1, String s2)
    return s1.indexOf(s2);
    public String getAppletInfo()
    return "Name: Beer Viewer.java\r\nLager Beer: 1.01\r\nPromouter: Best Beer\r\nBest Beer in the world!\r\nFamous light brand.\r\nLegendary Lager Beer\r\ne-mail: [email protected]";
    private void a(Graphics g1)
    g1.setColor(Color.white);
    g1.drawString("Best Beer in the world!", 125, 260);
    g1.drawString("Famous light brand.", 125, 270);
    g1.drawString("Legendary Lager Beer", 125, 280);
    g1.drawString("e-mail: [email protected]", 125, 290);
    private final void _mthfor(String s1)
    if(s1 == null || s1.length() == 0)
    d = false;
    StringBuffer stringbuffer = new StringBuffer();
    stringbuffer.append("Beer Viewer\n");
    if(d)
    stringbuffer.append("Ask for beer: ").append(s1).append("\n");
    stringbuffer.append("Best Beer in the world!, Famous light brand\n");
    stringbuffer.append("Legendary Lager Beer\n");
    stringbuffer.append("Codebase: ").append(getCodeBase().toString()).append("\n");
    stringbuffer.append("Documentbase: ").append(getDocumentBase().toString()).append("\n");
    k = stringbuffer.toString();
    if(d)
    o = new c(this, k);
    private void f()
    remove(q);
    q.invalidate();
    _mthvoid();

    yes

  • I'm having trouble writing a polynomial code.

    I'm having trouble with a polynomial code I'm supposed to conjour it. It's simply a code that adds, subtracts, and multiplies polynomials. However, there are a few methods I do not know how to come up with (I left them blank), and when I test the code write now, it doesn't work. Here's the code -- can anyone help?
    public class Polynomial implements Cloneable {
         private int m_degree;
         private double[] m_coefficient;
         // This is the default constructor
         public Polynomial() {
              super();
              m_degree = 0;
              m_coefficient = new double[5];
         // This allows the user to build a polynomial by putting a constant in
         public Polynomial(double constant) {
              this();
              m_coefficient[0] = constant;
         public Polynomial(Polynomial source) {
         // These are the getters
         public double getCoefficient(int degree) {
              return m_coefficient[degree];
         public int getDegree() {
              return m_degree;
         // These are the setters
         public void addToCoefficient(double amount, int degree) {
              m_coefficient[degree] += amount;
         public void assignCoefficient(double newCoefficient, int degree) {
              m_coefficient[degree] = newCoefficient;
         public void clear() {
              for (int i = 0; i < m_coefficient.length; i++) {
                   m_coefficient[i] = 0;
         public void reserve(int degree) {
         // These are other, useful methods
         public int nextTerm(int k) {
              int value = 0;
              return value;
         public double eval(double x) {
              double value = 0;
              // This goes through all the exponents in the polynomial
              for (int i = 0; i < getDegree(); i++) {
                   // += allows you to add instead of overriding the next term
                   value += getCoefficient(i) * Math.pow(x, i);
              return value;
         // Here is our addition method
         public static Polynomial add(Polynomial p1, Polynomial p2) {
              Polynomial newPolynomial = new Polynomial();
              // We have to find the bigger polynomial so we know how to set the loop
              if (p1.getDegree() >= p2.getDegree()) {
                   for (int i = 0; i < p1.getDegree(); i++) {
                        newPolynomial.addToCoefficient(p1.getCoefficient(i)
                                  + p2.getCoefficient(i), i);
              } else {
                   for (int i = 0; i < p2.getDegree(); i++) {
                        newPolynomial.addToCoefficient(p1.getCoefficient(i)
                                  + p2.getCoefficient(i), i);
              return newPolynomial;
         // Here is our subtraction method
         public static Polynomial subtract(Polynomial p1, Polynomial p2) {
              Polynomial newPolynomial = new Polynomial();
              // We have to find the bigger polynomial so we know how to set the loop
              if (p1.getDegree() >= p2.getDegree()) {
                   for (int i = 0; i < p1.getDegree(); i++) {
                        newPolynomial.addToCoefficient(p1.getCoefficient(i)
                                  - p2.getCoefficient(i), i);
              } else {
                   for (int i = 0; i < p2.getDegree(); i++) {
                        // The order is important with subtraction so they cannot be
                        // switched
                        // The equation is allowed to be negative, but the exponent
                        // cannot be
                        newPolynomial.addToCoefficient(p1.getCoefficient(i)
                                  - p2.getCoefficient(i), i);
              return newPolynomial;
         // Here is our multiplication method
         public static Polynomial multiply(Polynomial p1, Polynomial p2) {
              Polynomial newPolynomial = new Polynomial();
              if (p1.getDegree() >= p2.getDegree()) {
                   for (int i = 0; i < p1.getDegree(); i++) {
                        newPolynomial.addToCoefficient(p1.getCoefficient(i)
                                  * p2.getCoefficient(i), i);
              } else {
                   for (int i = 0; i < p2.getDegree(); i++) {
                        newPolynomial.addToCoefficient(p1.getCoefficient(i)
                                  * p2.getCoefficient(i), i);
              return newPolynomial;
         // Here is our clone method
         public Polynomial clone() {
              Polynomial poly;
              try {
                   poly = (Polynomial) super.clone();
              } catch (CloneNotSupportedException e) {
                   throw new RuntimeException(
                             "Class does not implement cloneable interface");
              return poly;
    }

    We've been working with arrays, and we have to write a code that adds, subtracts, and multiplies polynomials. I'm having trouble with a few of the methods. I've assigned m_degree and m_coefficient as the fields I need to use.
    Right now, as my code stands, when I test it with a polynomial in main, it doesn't work. So right now, there's a mistake preventing what I have so far from properly functioning.
    I am also having trouble writing the following methods:
    reserve: We have to allocate memory to the polynomial every time it changes so we make sure we always have enough space to work with it.
    nextTerm: We need this to jump to the next term in the polynomial, but I'm not quite sure how to do it. I didn't even realize it was possible.
    I'm horrible at commenting and explaining my code, but if you read over it just a little bit, you may be able to get the gist of what I'm trying to do. Thanks for any help, and sorry if I can't explain well.
    public class Polynomial implements Cloneable {
    private int m_degree;
    private double[] m_coefficient;
    // This is the default constructor
    public Polynomial() {
    super();
    m_degree = 0;
    m_coefficient = new double[5];
    // This allows the user to build a polynomial by putting a constant in
    public Polynomial(double constant) {
    this();
    m_coefficient[0] = constant;
    public Polynomial(Polynomial source) {
    // These are the getters
    public double getCoefficient(int degree) {
    return m_coefficient[degree];
    public int getDegree() {
    return m_degree;
    // These are the setters
    public void addToCoefficient(double amount, int degree) {
    m_coefficient[degree] += amount;
    public void assignCoefficient(double newCoefficient, int degree) {
    m_coefficient[degree] = newCoefficient;
    public void clear() {
    for (int i = 0; i < m_coefficient.length; i++) {
    m_coefficient[i] = 0;
    public void reserve(int degree) {
    // These are other, useful methods
    public int nextTerm(int k) {
    int value = 0;
    return value;
    public double eval(double x) {
    double value = 0;
    // This goes through all the exponents in the polynomial
    for (int i = 0; i < getDegree(); i++) {
    // += allows you to add instead of overriding the next term
    value += getCoefficient(i) * Math.pow(x, i);
    return value;
    // Here is our addition method
    public static Polynomial add(Polynomial p1, Polynomial p2) {
    Polynomial newPolynomial = new Polynomial();
    // We have to find the bigger polynomial so we know how to set the loop
    if (p1.getDegree() >= p2.getDegree()) {
    for (int i = 0; i < p1.getDegree(); i++) {
    newPolynomial.addToCoefficient(p1.getCoefficient(i)
    + p2.getCoefficient(i), i);
    } else {
    for (int i = 0; i < p2.getDegree(); i++) {
    newPolynomial.addToCoefficient(p1.getCoefficient(i)
    + p2.getCoefficient(i), i);
    return newPolynomial;
    // Here is our subtraction method
    public static Polynomial subtract(Polynomial p1, Polynomial p2) {
    Polynomial newPolynomial = new Polynomial();
    // We have to find the bigger polynomial so we know how to set the loop
    if (p1.getDegree() >= p2.getDegree()) {
    for (int i = 0; i < p1.getDegree(); i++) {
    newPolynomial.addToCoefficient(p1.getCoefficient(i)
    - p2.getCoefficient(i), i);
    } else {
    for (int i = 0; i < p2.getDegree(); i++) {
    // The order is important with subtraction so they cannot be
    // switched
    // The equation is allowed to be negative, but the exponent
    // cannot be
    newPolynomial.addToCoefficient(p1.getCoefficient(i)
    - p2.getCoefficient(i), i);
    return newPolynomial;
    // Here is our multiplication method
    public static Polynomial multiply(Polynomial p1, Polynomial p2) {
    Polynomial newPolynomial = new Polynomial();
    if (p1.getDegree() >= p2.getDegree()) {
    for (int i = 0; i < p1.getDegree(); i++) {
    newPolynomial.addToCoefficient(p1.getCoefficient(i)
    * p2.getCoefficient(i), i);
    } else {
    for (int i = 0; i < p2.getDegree(); i++) {
    newPolynomial.addToCoefficient(p1.getCoefficient(i)
    * p2.getCoefficient(i), i);
    return newPolynomial;
    // Here is our clone method
    public Polynomial clone() {
    Polynomial poly;
    try {
    poly = (Polynomial) super.clone();
    } catch (CloneNotSupportedException e) {
    throw new RuntimeException(
    "Class does not implement cloneable interface");
    return poly;
    }

  • Writing file through code

    Hi,
    I want to write data to a file but it gives security error.
    AcceccControl Exception file write
    I used
    FilePermission f=new FilePErmission(String message,"write");
    Please send me suggestions.
    bye.

    Hallo,
    From what you say, you are developing an applet. I have not tried to write files from an applet, so it is difficult for me to give you further advice. It may (I do not know for certain) be necessary to set up a FilePermission before starting to write, but it is certainly not sufficient in the mathematical sense. I assume the your message is what you want to write to the file. In this case your proposed code fragment is wrong. According to the API documentation:
    public FilePermission(String path,
    String actions)
    Creates a new FilePermission object with the specified actions. path is the pathname of a file or directory, and actions contains a comma-separated list of the desired actions granted on the file or directory. Possible actions are "read", "write", "execute", and "delete".
    A pathname that ends in "/*" (where "/" is the file separator character, File.separatorChar) indicates a directory and all the files contained in that directory. A pathname that ends with "/-" indicates a directory and (recursively) all files and subdirectories contained in that directory. The special pathname "<<ALL FILES>>" matches all files.
    A pathname consisting of a single "*" indicates all the files in the current directory, while a pathname consisting of a single "-" indicates all the files in the current directory and (recursively) all files and subdirectories contained in the current directory.
    Parameters:
    path - the pathname of the file/directory.
    actions - the action string.
    I do not see anything in this description that says that this function does your writing.

  • Good ideas for pattern design to achieve small code size?

    Hi there,
    i am developing a benchmark set for testing Java performance on J2ME. As this is for resource-constrained devices (PDA, cellphone), the code's size should be as small as possible.
    Here is the funny question: for example i have a class with name "LoopBenchmark", it has its own configuration such as "loop times", "operationType". The main program, running on a desktop could judge the configuration and load the class, Say with following snippet:
    switch(operationType) {
    case: ASSIGNMENT
    for (int i = 0; i < loopTimes; i++)
    int test = 123;
    break;
    case: ADDITION
    for (int i = 0; i < loopTimes; i++)
    int test = 3+7;
    break;
    case: MULTIPLICATION
    for (int i = 0; i < loopTimes; i++)
    int test = 3*7;
    break;
    default:
    System.out.println("unknown operation type");
    I want to create a JAR which could be load to a PDA and running there later. Of course, i hope the JAR could be as small as possible. How can i get just for example:
    for (int i = 0; i < loopTimes; i++)
    int test = 3+7;
    if i know already from the configuration that user wants to run addtion only? I don't want to pack all such SWITCH-CASE handling into the JAR file. Any ideas?
    cheers,
    eedych

    i think that what YATArchivist said goes further than that..
    int switchSelector=2;
    switch(switchSelector){
    case: 0
    //effectively not compiled
    case: 1
    //effectively not compiled
    case: 2
    //yeah you will get this bit
    .....its a guess bassed on faith in the compiler, i admit, but worth a look
    very possible to do, and even 20 year old compilers did this, so i see no reaon why java wont, they would calculate the range of values a variable may have at any point and issue warnings if your program was going to generate errors/ contain redundant code

  • JLabel on JPanel Disappears(Small CODE!)

    Um... I had posted a message a earlier just ot make the complex problem simpler. I have made this small version of my massive code and again the JLabel does not get displayed on the JPanel.
    This is urgent please help me.
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    class LabelTry
         public static void main(String args[])
              JFrame aFrame= new JFrame("This is a Test");
              aFrame.addWindowListener(new WindowAdapter()
              {public void windowClosing(WindowEvent e)
              {System.exit(0);
              aFrame.setSize(500,500);
              Container c = aFrame.getContentPane();
              JPanel secPanel = new JPanel();
              secPanel.setLayout(null);
              secPanel.setBackground(Color.gray);
              secPanel.setBorder(BorderFactory.createEtchedBorder());
              JLabel aLabel = new JLabel(" ");
              aLabel.setBounds(100,100,10,10);
              aLabel.setBackground(Color.black);
              aLabel.setOpaque(false);
              aLabel.setVisible(true);
              secPanel.setOpaque(false);
              secPanel.add(aLabel);
              c.add(secPanel, BorderLayout.CENTER);
              aFrame.setVisible(true);
         }//end main
    }//end class LabelTry

    I've got it working now, but I cannot get it to work in a bigger program.
    the code that runs properly is as follows
    /;code
    class LabelTry
         public static void main(String args[])
              JFrame aFrame= new JFrame("This is a Test");
              aFrame.addWindowListener(new WindowAdapter()
              {public void windowClosing(WindowEvent e)
              {System.exit(0);
              aFrame.setSize(500,500);
              Container c = aFrame.getContentPane();
              JPanel secPanel = new JPanel();
              secPanel.setLayout(null);
              secPanel.setBackground(Color.gray);
              secPanel.setOpaque(false);
              secPanel.setBorder(BorderFactory.createEtchedBorder());
              JLabel aLabel = new JLabel(" ");
              aLabel.setBounds(200,200,10,10);
              aLabel.setBackground(Color.black);
              aLabel.setOpaque(true);
              aLabel.setVisible(true);
              secPanel.add(aLabel);
              c.add(secPanel, BorderLayout.CENTER);
              aFrame.setVisible(true);
         }//end main
    }//end class LabelTry
    //end code

  • Problem with a small code

    Hello , Can anyone plz tell me how do i get this output from this sample code ? im new to java...
    public class Fact2
    int factorial (int n) {
    int res;
    System.out.println(n);
    if (n == 1) return 1;
    res = factorial (n - 1) * n ;
    System.out.println("res " + res);
    return res;
    public static void main (String [] args) {
    Fact2 f= new Fact2();
    System.out.println("The factorial of this number is " + f.factorial(5));
    The output is :
    C:\Documents and Settings\AM>java Fact2
    5
    4
    3
    2
    1
    res 2
    res 6
    res 24
    res 120
    The factorial of this number is 120
    Here , from 5 to 1 is understood and also the last phrase of course , but from where did the variable "res" have these values 2,6,24 ....

    2: int factorial (int n) {
    3: int res;
    4: System.out.println(n);
    5: if (n == 1) return 1;
    6: res = factorial (n - 1) * n ;
    7: System.out.println("res " + res);
    8: return res;
    9: }
    When you call factorial(5) this will happen:
    It prints 5 (line 4)
    It calls factorial(4) (line 6) - (and waits for it result!!!!!)
    factorial(4) shall print 4, and calls factorial(3)
    prints 3, calls factorial(2)
    prints 2, calls factorial(1)
    prints 1, returns 1returns from factorial(1), multiplies it by 2 (line 6), result = 2
    prints the result to the screen (line 7)
    returns the result (line 8) (thus 2)multiplies the result of factorial(2) with 3 (line 6), result = 6
    prints this result, and returns itmultiplies the result of factorial(3) with 4, result = 24
    prints this result, and returns itmultiplies the result of factorial(4) with 5, result = 120
    prints this result and returns itHope this get things clear to you

  • Just want to know it this small code is right

    Hello everyone, im back :P
    well, i've been doing exercises, but i don't have the solution yet...so could you tell me if this code is right? thanks.
    About the constructors etc..i think its right, but i not sure about the last method ( distanceFromTwoPoints() )
    If i'd like to test this class, i would ask for 4 coord. (x1,y1) and (x2, y2)..
    And solved the distance between those two points..well
    I don't understand..
    On that code how can i calculate the distance from two points if i just have x1 and y1, i mean ...when i wrote that boolean method ( if the two points are equal) the the "p" variable reference is pointing to x1 and y1 , right? maybe that boolean method is wrong too, cuz i want to compare (x1, y1 ) with (x2, y2) well....when i wrote :
    this.x1 == p.x1 etc both are references to x1 and y1, so returns always true.
    Do i need to write a setMethod to change the values ?
    Is that code comparing two points? thats all i want to know...if yes, so how can i test it?
    public class Point {
         private double x1;
         private double y1;
         public Point(final double x1, final double y1){
              this.x1 = x1;
              this.y1 = y1;          
         public double getX1() {
              return x1;
         public double getY2() {
              return y1;
         public boolean isEqual(final Point p){
              return (this.x1 == p.x1 && this.y1 == p.y1);
         public double distanceFrom2Points (int x1, int y2, Point p){
              return Math.sqrt((this.x1 - p.x1)*(this.x1 - p.x1) + (this.y1 - p.y1)*(this.y1 - p.y1));
    I think this code is just working with two coord. x1 and y1 :S where do i put x2 and y2?
    "p" is a reference to the x1 and y1 variables, so where are the x2 and y2?
    im confused :P
    thanks

    public class Point {
         private double x;
         private double y;
         public Point(final double x, final double y){
              this.x = x;
              this.y = y;          
         public double getX() {
              return x;
         public double getY() {
              return y;
         public boolean isEqual(final Point p){
              return (this.x == p.x && this.y == p.y);
         public double distanceFrom2Points ( Point p){
    return Math.sqrt((this.x - p.x) * (this.x - p.x) + (this.y - p.y) * (this.y - p.y));
    public class TestingPoint {
         public static void main(String[] args) {
              System.out.print("X1: ");
              double x1 = Teclado.doubleLido();
              System.out.print("Y1: ");
              double y1 = Teclado.doubleLido();  
              //Teclad.intLido() reads from the console, something like:
             //Keyboard.intRead(); we use that.
              System.out.print("X2: ");
              double x2 = Teclado.doubleLido();
              System.out.print("Y2: ");
              double y2 = Teclado.doubleLido();
              Point p1 = new Point(x1, y1);
              Point p2 = new Point(x2, y2);
        double distance = p2.distanceFrom2Points(p1.distanceFrom2Points
                                                   (x1,x2));
         System.out.println("The distance is "+distance);
    }the compilation ERROR says: The method distanceFrom2Points(Point) in the type Point is not applicable for the arguments (double, double)
    these are the two classes.
    What is wrong ?
    thanks!

  • Can't find the error on this small code :S

    Hi , i've just compiled this code and i can't find what is wrong! :(
    The compiler is ok, but the output print its not what i was expect.
    If u insert 121 (capicua) the answer is: This number its not a capicua :S
    what is wrong?
    thanks!!
    Note: Don't create another code plz.
    import java.io.*;
    public class Capicua {
         public static void main (String[] args) throws Exception {
              int digit, num;
              int inverted = 0;
                   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                   System.out.print(" Insert number: ");
                   num=Integer.parseInt(br.readLine().trim());
                   while(num > 0) {
                   digit = num % 10;
                   num = num /10;
                   inverted = inverted * 10 + digit;
                   if(num == inverted) {
                        // to be capicua the number inserted must
                        //be equals to the inverted
                        System.out.println("Its Capicua!");      
                   }else{
                        System.out.println("This number is not a Capicua!");
    }

    Please use code tags (see button above posting box) when posting code. It makes it much easier to read.
    So, it appears that capicua means palindrome--the number reads the same backwards and forwards. Is that correct?
    There are ways of doing this without converting the 121 to a number, but I won't explain that unless you want.
    I think your problem is this line:
    if (num == inverted)
    You have changed "num" within your while loop. Therefore, num is no longer the original input 121.
    Try adding println statements like this to watch what happens:
    while(num > 0) {
      digit = num % 10;
      num = num /10;
      inverted = inverted * 10 + digit;
      System.out.println("digit = " + digit);
      System.out.println("num = " + num);
      System.out.println("inverted = " + inverted);
    }

  • Can somebody please help me with this? Security code issue; very small code

    Hi All, Iam a Unix admin and trying to learn Java/weblogic. I have a JSP and iam trying to run on my weblogic 81 Service Pack version 3.
    My following code failed to work and giving me some security exceptions. Then in my weblogic console i saw
    Domain Wide Security Settings > Anonymous Admin Lookup Enabled
    The above checkbox is disabled. When i enabled, it worked. I talked to my company "Security" folks and they do not allow this checkbox to be enabled. they are saying fix your code problem......
    if somebody can please let me know what a probable fix would, that be great and very helpful.
    try{
    Environment env = new Environment();   
    javax.naming.InitialContext ic = new InitialContext();
    MBeanHome home = (MBeanHome) ic.lookup(MBeanHome.LOCAL_JNDI_NAME);
    DomainMBean dom = home.getActiveDomain();
    Set s = home.getMBeansByType("ServerRuntime");
    ServerRuntimeMBean srmb = (ServerRuntimeMBean) s.iterator().next();
    WebLogicObjectName on = new WebLogicObjectName(home.getDomainName()+":Location="+srmb.getName()+",Name="+srmb.getName()+",Type=ServerConfig");
    //WebLogicObjectName on = new WebLogicObjectName(Name="+srmb.getName()+",Type="ServerConfig",Domain="+home.getDomainName()+",Location="+srmb.getName()+");
    ServerMBean server = (ServerMBean) home.getMBean(on);
    ClusterMBean cluster = null;
    if( server != null)
        cluster = server.getCluster();

    did i asked such a dumb question? ... :)Well, yes, sort of. The problem description "My following code failed to work and giving me some security exceptions" doesn't have nearly enough details. Such as, what exceptions, what is it supposed to do, what did it do instead, that sort of thing.

Maybe you are looking for

  • Re: sales analysis report

    HI, New to SAP B1.I need to modify selection criteria, instead of pulling all group items,I need to hard code it to one perticular item group code. Please help me how to do it. Thanks in advance.

  • Help with purchasing correct network card

    Hi, I'm trying to set up a wireless network for a friend who has an IBook G3 purchased in December 2002 which I know makes it very old. I have a 802.11g wireless ADSL router successfully set up and the IBook can connect to the internet successfully t

  • How to reload sound modules?

    I'm using alsa + pulse sound system. I also have Openbox as a stand-alone WM and lightDM,  but the same thing occurs on my debian testing + gnome. I've been trying to solve this issue for several days but with no success. Below is the output from als

  • I need to merge two clips

    AHH!! I really need to merge these two clips, the videos just split for no reason and it sounds sorta like heh..heh eeeee I REALLY need to fix it A.S.A.P.!!!!! Please help! Thanks!!!! Q.T

  • EDI Creating sales order.?

    my inbound ORDERS idoc is creating the sales order successfully with status 53. Storage location is maintained in my inbound idoc-data records (E1EDP01), But in my transaction VA02, Storage location is not updated . Can any one help in this issue?