• Donnie Isaac
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
Hi all. Learning Apex here. Refere to code and question below:

Code:
public class myClass {
   static final Integer PRIVATE_INT_CONST;
   static final Integer PRIVATE_INT_CONST2 = 200;
   public static Integer calculate () {
          return 2 + PRIVATE_INT_CONST2;
   }
   static {
         PRIVATE_INT_CONST = calculate ();
   }

}

Trying to get this code [ see code below] to (run in Execute Anonymous and ) return what I think should be '202'.  At first I tried to run this code and added System.debug (PRIVATE_INT_CONST); and the error was that only top level class variables can be declared static. [ What is a top level class? Is this just an outer classs?] So I created the class as a new class. Now that the class is created, it seems that it is reconizing it. So I simply entered System.debug(myClass.PRIVATE_INT_CONST); in the Execute Anonymous window and the error is that the variable is not visible. Can anyone help me correct the code so that it will run? What am I doing wrong? Thanks! 

 
Hi all,

I'm relatively new to Apex and I have been studying the Apex for non-coders. I have run into a snag in that the code I am including below runs in Execute Anonymous on Force.com IDE, but won't run in the main window so I can't save it to the server. I am using windows 8, Eclipse 4.4, Force.com IDE 33.0 and have no problems with anything else. On line 10 it gives me: unexpected syntax: missing EOF at 'BankAcct'
I haven't been able to fix the error (I tried deleting the curly brace, adding one, moving things around, nothing worked) and can't spot any syntax errors otherwise (since it runs in Execute Anon,) so anyone got ideas? Thanks!

public class BankAcct {
     private integer balance = 0;
     public string acctName;
       public string accttype;
       public void makeDeposit (integer deposit){
           balance = balance + deposit;
        }
    public integer getBalance() {
          return balance;
    }

BankAcct chkAcct = new BankAcct();
chkAcct.accttype = 'Checking';
chkAcct.acctName = 'D.Castillo-Chk ';
chkAcct.makeDeposit(150);
BankAcct savAcct = new BankAcct();
savAcct.accttype = 'Savings';
savAcct.acctName = 'D.Castillo–Sav';
savAcct.makeDeposit(220);
List <BankAcct> bankAccts = new List<BankAcct>();
System.debug('The BankAcct List has ' + bankAccts.size() + ' bank  accounts.');
bankAccts.add(chkAcct);
bankAccts.add(savAcct);
System.debug('The BankAcct List has ' + bankAccts.size() + ' bank    accounts.');
System.debug('Here is the list: ' + bankAccts);
For (BankAcct  tempacct:bankAccts)

 system.debug(tempacct.acctName + ' is a ' + tempacct.accttype +' account with a balance of $'+ tempacct.getBalance());
 }

 
Hi all. Learning Apex here. Refere to code and question below:

Code:
public class myClass {
   static final Integer PRIVATE_INT_CONST;
   static final Integer PRIVATE_INT_CONST2 = 200;
   public static Integer calculate () {
          return 2 + PRIVATE_INT_CONST2;
   }
   static {
         PRIVATE_INT_CONST = calculate ();
   }

}

Trying to get this code [ see code below] to (run in Execute Anonymous and ) return what I think should be '202'.  At first I tried to run this code and added System.debug (PRIVATE_INT_CONST); and the error was that only top level class variables can be declared static. [ What is a top level class? Is this just an outer classs?] So I created the class as a new class. Now that the class is created, it seems that it is reconizing it. So I simply entered System.debug(myClass.PRIVATE_INT_CONST); in the Execute Anonymous window and the error is that the variable is not visible. Can anyone help me correct the code so that it will run? What am I doing wrong? Thanks! 

 
Hi all,

I'm relatively new to Apex and I have been studying the Apex for non-coders. I have run into a snag in that the code I am including below runs in Execute Anonymous on Force.com IDE, but won't run in the main window so I can't save it to the server. I am using windows 8, Eclipse 4.4, Force.com IDE 33.0 and have no problems with anything else. On line 10 it gives me: unexpected syntax: missing EOF at 'BankAcct'
I haven't been able to fix the error (I tried deleting the curly brace, adding one, moving things around, nothing worked) and can't spot any syntax errors otherwise (since it runs in Execute Anon,) so anyone got ideas? Thanks!

public class BankAcct {
     private integer balance = 0;
     public string acctName;
       public string accttype;
       public void makeDeposit (integer deposit){
           balance = balance + deposit;
        }
    public integer getBalance() {
          return balance;
    }

BankAcct chkAcct = new BankAcct();
chkAcct.accttype = 'Checking';
chkAcct.acctName = 'D.Castillo-Chk ';
chkAcct.makeDeposit(150);
BankAcct savAcct = new BankAcct();
savAcct.accttype = 'Savings';
savAcct.acctName = 'D.Castillo–Sav';
savAcct.makeDeposit(220);
List <BankAcct> bankAccts = new List<BankAcct>();
System.debug('The BankAcct List has ' + bankAccts.size() + ' bank  accounts.');
bankAccts.add(chkAcct);
bankAccts.add(savAcct);
System.debug('The BankAcct List has ' + bankAccts.size() + ' bank    accounts.');
System.debug('Here is the list: ' + bankAccts);
For (BankAcct  tempacct:bankAccts)

 system.debug(tempacct.acctName + ' is a ' + tempacct.accttype +' account with a balance of $'+ tempacct.getBalance());
 }

 
Hello!, 

Everytime we want to save a cloned product this error appears, so we have to create the product from scratch, it is only when we clone the products that this error appears (It did not appear before). Does anyone has had this problem? If so could you fix it?. 
User-added image


Thanks!