Error using Arrays.toString()

Hi there,
I am getting the following error using Arrays.toString on a String Array. 'toString() in java.lang.Object cannot be applied to (java.lang.String[]).
The line in question is at the bottom of the below code. It starts 'rtitem.appendText.....
import lotus.domino.*;
//import java.util.Arrays;
public class JavaAgent extends AgentBase {
     Database curDb;
     String[] dbList;
     public void NotesMain() {
     int dbcount = 0;
          try {
               Session session = getSession();
               AgentContext agentContext = session.getAgentContext();
               //get current database
               Database curDb = agentContext.getCurrentDatabase();
               //build a list of servers;
               String[] servers = {"Norwich002/Norwich/MoneyCentre","Norwich003/MoneyCentre","Norwich004/MoneyCentre","Norwich005/MoneyCentre","Norwich007/Norwich/MoneyCentre","Norwich008/Norwich/MoneyCentre","Norwich010/Norwich/MoneyCentre","Norwich020/Norwich/MoneyCentre","Norwich021/Norwich/MoneyCentre"};
               //loop through server list
               int arraylen = servers.length;
               for(int i=0;i <= arraylen;i++){
                    //create a notesdbdirectory collection for the current server iteration
                    DbDirectory dbdir = session.getDbDirectory(servers);
                    //get first database
                    Database db = dbdir.getFirstDatabase(DbDirectory.DATABASE);
                    //loop through databases in dbdir
                    while (db != null){
                         //add database details to our list
                         dbList[dbcount] = db.getTitle() + " - " + db.getFilePath();
                         dbcount++;     
          } catch(Exception e) {
               e.printStackTrace();
          private boolean sendEmail(String subject){
               try{
                    Document mailDoc = curDb.createDocument();
                    mailDoc.replaceItemValue("SendTo","Hayleigh S Mann/Norwich/MoneyCentre");
                    mailDoc.replaceItemValue("Subject",subject);
                    RichTextItem rtitem = mailDoc.createRichTextItem("Body");
                    rtitem.appendText(java.util.Arrays.toString(dbList));
                    mailDoc.send();
                    return true;
               }catch(Exception e){
                    e.printStackTrace();
                    return false;

No, that doesn't make any sense. Arrays.toString can take any array as an arg: [http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#toString(java.lang.Object[])]
import java.util.*;
public class A {
  public static void main(String[] args) {
    String str = Arrays.toString(args);
    System.out.println(str);
:; java -cp . A abc 123 xxx
[abc, 123, xxx]

Similar Messages

  • Help with this error using arrays

    The class that im working on is called PhoneCalc and im trying to create a local variable called ProductCode which needs to be a String.
    but dont change the ConsoleInput at the bottom of the thread
    then modify the loop so it displays full order details e.g
    Product Code: Manufacturer Price
    * Write a description of class PhoneCalc here.
    *  (Abol Akrami)
    public class PhoneCalc
        private double[] Prices = new double[ 5 ];
        private String[] ProductCodes = new String[ 15 ];
        private String[] Manufacturers = new String[ 15 ];
        public PhoneCalc()  {}
        public void AddPhonePricesWithLoop () {
        double Price;
        String ProductCode;
        String Manufacturer;
        for (int IndexNum = 0; IndexNum <5; IndexNum++) {
           System.out.println("Please enter price of phone");
           Prices [ IndexNum ] = ConsoleInput.readDoubleValue();       
        for (int IndexNum = 0; IndexNum < Prices.length; IndexNum++) {
           System.out.println ("Please enter the product code");
           ProductCodes[ IndexNum ] = ConsoleInput.readStringObject();      
        for (int IndexNum = 0; IndexNum < 5; IndexNum++) {
            System.out.println ("Please enter Manufacturer");
            Manufacturers [ IndexNum ] = ConsoleInput.readStringObject();
           for (int IndexNum = 0; IndexNum <Prices.length; IndexNum++)
            System.out.println ("Product Code:" + ProductCodes[ IndexNum ] + ",Price �" +
            Prices[ IndexNum ] + "Manufacturers:" + Manufacturers[ IndexNum ]);
            public static void main (String[] args) {
            PhoneCalc sys = new PhoneCalc ();
            sys.AddPhonePricesWithLoop ();
    }ConsoleInput
    import java.io.*;
    * Write a description of class ConsoleInput here.
    * @author (your name)
    * @version (a version number or a date)
    public class ConsoleInput
        public static char readCharValue () {
           BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
           char c = '\0';
           try {
              c = Inputter.readLine ().charAt (0);
           } catch (IOException e) {
              System.err.println ("Invalid character entered");
           return c;
        public static int readIntValue () {
           BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
           int i = 0;
           try {
               i = Integer.parseInt (Inputter.readLine ());
           } catch (IOException e) {
              System.err.println ("Invalid value entered");
           return i;
        public static long readLongValue () {
           BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
           long l = 0;
           try {
              l = Long.parseLong (Inputter.readLine ());
           } catch (IOException e) {
              System.err.println ("Invalid value entered");
           return l;
        public static float readFloatValue () {
           BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
           float f = 0;
           try {
              f = Float.parseFloat (Inputter.readLine ());
           } catch (IOException e) {
              System.err.println ("Invalid value entered");
           return f;
        public static double readDoubleValue () {
           BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
           double d = 0;
           try {
              d = Double.parseDouble (Inputter.readLine ());
           } catch (IOException e) {
              System.err.println ("Invalid value entered");
           return d;
        public static String readStringObject () {
           BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
           String str = null;
           try {
              str = Inputter.readLine ();
           } catch (IOException e) {
              System.err.println ("Invalid text entered");
           return str;
    }

    errr... whats your problem then?

  • Getting "Method 'sign_in' does not exist" Error (using Charles)

    This may be a bit off the FLEX field, and have to do with Zend Framework's ZEND_AMF class. Unfortunately I haven't been able to dig anything up, and comments posted on Wade Arnolds site have not received any responses, so I thought I'd give it a go here.
    My ServiceController Class:
    public function loginAction()
         $this->_helper->viewRenderer->setNoRender();
         $server = new Zend_Amf_Server();
         $server->setClass('LoginAmfService', 'LoginService');
         $server->setClassMap('CurrentUserVO', 'CurrentUserVO');
         $server->setProduction(false);
         print($server->handle());
    My LoginAmfService class:
    class LoginAmfService
          * Main login function.
          * @param  string        $name
          * @param  string        $password
          * @return CurrentUserVO
         public function sign_in($name, $password)
              $authAdapter     = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('db'), 'users', 'user_name', 'password', 'PASSWORD(?) AND active = 1');
              $returnValue     = new CurrentUserVO();
              $authAdapter->setIdentity(htmlspecialchars($name))
                   ->setCredential(htmlspecialchars($password));
              $authResult = $authAdapter->authenticate();
              if ($authResult->isValid())
                   $userArray                          = $authAdapter->getResultRowObject(array('id', 'first_name', 'last_name', 'title', 'photo'));
                   $returnValue->first_name     = $userArray->first_name;
                   $returnValue->last_name          = $userArray->last_name;
                   $returnValue->title               = $userArray->title;
                   $returnValue->photo               = $userArray->photo;
                   $returnValue->token               = $userArray->id;
              return $returnValue;
          * Function used to log people off.
         public function sign_out()
              $authAdapter = Zend_Auth::getInstance();
              $authAdapter->clearIdentity();
    My SignIn FLEX module (the relevant portions):
         <mx:RemoteObject
              id="LoginRemote"
              destination="login"
              source="SignIn"
              showBusyCursor="true"
              fault="parentDocument.handleFault(event)"
         >
               <mx:method name="sign_in" result="signin_handle(event)" />
               <mx:method name="sign_out" result="signout_handle(event)" />
         </mx:RemoteObject>
         <mx:Script>
              <![CDATA[
                   import mx.rpc.events.FaultEvent;
                   import mx.utils.ArrayUtil;
                   import mx.rpc.events.ResultEvent;
                   import mx.controls.Alert;
                   import com.brassworks.ValueObjects.CurrentUserVO;
                   import mx.events.VideoEvent;
                   [Bindable]
                   private var this_user:CurrentUserVO = new CurrentUserVO();
                   private function mdl_init():void
                        focusManager.setFocus(txt_username);
                   private function signin_handle(event:ResultEvent):void
                             this_user = event.result as CurrentUserVO;
                             if (this_user.token == null) {Alert.show("Supplied login credentials are not valid. Please try again.");}
                             else
                                  this.parentApplication.setUser(this.this_user);
                   private function signout_handle(event:ResultEvent):void
                   private function sign_in(event:Event):void
                        try
                             //Alert.show(txt_name.text + "|" + txt_password.text);
                             LoginRemote.sign_in(txt_username.text, txt_password.text);
                        catch (error:Error)
                             this.parentDocument.handleFault(error);
                   private function sign_out(event:Event):void
                   private function show_error(error:Error, s_function:String):void
                        Alert.show("Method:" + s_function + "\nName: " + error.name + "\nID: " + error.errorID + "\nMessage: " + error.message + "\nStack Trace: " + error.getStackTrace() + "\nError: " + error.toString());
                   private function handleFault(event:FaultEvent):void
                        Alert.show(event.fault.faultDetail, event.fault.faultString);
              ]]>
         </mx:Script>
    Now, all this is great and good, as it works with Zend Framework 1.7.6. However, when I try to upgrade to 1.7.8 (to take advantage of session management and other bug-fixes), I get the following error (using Charles):
    #1 /var/web/htdocs/core/library/Zend/Amf/Server.php(390): Zend_Amf_Server->_handle(Object(Zend_Amf_Request_Http))
    #2 /var/web/htdocs/core/application/default/controllers/ServicesController.php(73): Zend_Amf_Server->handle()
    #3 /var/web/htdocs/core/library/Zend/Controller/Action.php(503): ServicesController->loginAction()
    #4 /var/web/htdocs/core/library/Zend/Controller/Dispatcher/Standard.php(285): Zend_Controller_Action->dispatch('loginAction')
    #5 /var/web/htdocs/core/library/Zend/Controller/Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
    #6 /var/web/htdocs/core/application/bootstrap.php(39): Zend_Controller_Front->dispatch()
    #7 /var/web/htdocs/core/public/index.php(5): Bootstrap->runApp()
    #8 {main} ?Method "sign_in" does not exist
    I have no idea why this would not work anymore. My assumption is that I am not correctly setting up Zend_Amf (but then again, my counter-argument is that it worked before, so ..... ????)
    Thanks for any help!
    -Mike

    For those that are also fighting this issue:
    The problem appears to be that the RemoteObject needs to specify the class containing the methods as a source parameter. According to this bug report (http://framework.zend.com/issues/browse/ZF-5168) it is supposed to have been addressed, but apparently has re-emerged in Zend_Amf since version 1.7.7.
    Using my example above, I would have to specify the RO as:
    <mx:RemoteObject
              id="LoginRemote"
              destination="login"
              source="LoginAmfService"
              showBusyCursor="true"
              fault="parentDocument.handleFault(event)"
         >
               <mx:method name="sign_in" result="signin_handle(event)" />
               <mx:method name="sign_out" result="signout_handle(event)" />
         </mx:RemoteObjecct>

  • Using arrays in JAVA

    Hi Guys,
    I always had a few problems using arrays and now I need to use them and I am stuck.
    on my program i need to create an array of int with the numbers 1 to 1000 in it for this I have done:
    int[ ] array;
    on the class constructor
    array = new int[1000];
    to fill the array:
    for (int i = 0; i < array.length; i++)
         array[i] = i;
    The problem is that I always get an ArrayIndexOutOfBoundsException error.
    I know how to solve it which is to create an array with 1001 elements but is there a more elegant way of creating the array or this is the way to do it?
    To put my question in another way if any of you Guys was creating this program which way would you do it.
    Best regards
              Luis

    Sloppy of me. This is a bit better:
    package cruft;
    import java.util.Arrays;
    * A class for a one-based array of ints.
    public class OneBasedIntArray
       private int [] values;
       public static void main(String[] args)
          int [] values = new int[args.length];
          for (int i = 0; i < args.length; i++)
             values[i] = Integer.parseInt(args);
    OneBasedIntArray intArray = new OneBasedIntArray(values);
    System.out.println(intArray);
    public OneBasedIntArray(int[] values)
    this.values = new int[values.length];
    System.arraycopy(values, 0, this.values, 0, values.length);
    public int getValue(int index)
    if (index <= 0)
    throw new IllegalArgumentException("this array is one-based");
    return values[index-1];
    public void setValue(int index, int value)
    if (index <= 0)
    throw new IllegalArgumentException("this array is one-based");
    this.values[index-1] = value;
    public boolean equals(Object o)
    if (this == o)
    return true;
    if (o == null || getClass() != o.getClass())
    return false;
    OneBasedIntArray intArray = (OneBasedIntArray) o;
    if (!Arrays.equals(values, intArray.values))
    return false;
    return true;
    public int hashCode()
    return (values != null ? Arrays.hashCode(values) : 0);
    public String toString()
    StringBuilder builder = new StringBuilder();
    builder.append("OneBasedIntArray{");
    for (int i = 0; i < values.length; i++)
    builder.append("(").append(i+1).append(",").append(values[i]).append(")");
    builder.append('}');
    return builder.toString();

  • Using array binding to perform multiple rowupdates in one pass

    For the first time I am attempting to use array binding in VB.NET to update multiple rows via a single execution of a stored procedure. My subroutine is:
    Friend Sub UpdateSolutionStatusUsingArrays(ByVal intNumBeingUpdated As Integer, ByVal arrScenarioID() As Integer, ByVal arrSolutionID() As Integer, ByVal arrInOrOut() As Integer, ByVal arrTimePeriod() As Integer)
    Try
    'Set up the Command object
    Dim cmdUpdateSolutionStatus As OracleCommand
    cmdUpdateSolutionStatus = New OracleCommand
    cmdUpdateSolutionStatus.CommandType = CommandType.StoredProcedure
    cmdUpdateSolutionStatus.CommandText = "ProcUpdateSolutionStatus"
    cmdUpdateSolutionStatus.Connection = cnnORACLE
    cmdUpdateSolutionStatus.ArrayBindCount = intNumBeingUpdated - 1
    cmdUpdateSolutionStatus.CommandTimeout = CInt(tblOptions.Rows(intDatabaseIndex).Item("ConnectionTimeout"))
    'Add ScenarioID array as parameter
    Dim p_ScenarioID As New OracleParameter("ScenarioID", OracleDbType.Int32)
    p_ScenarioID.Direction = ParameterDirection.Input
    p_ScenarioID.Value = arrScenarioID
    cmdUpdateSolutionStatus.Parameters.Add(p_ScenarioID)
    'Add SolutionID array as parameter
    Dim p_SolutionID As New OracleParameter("SolutionID", OracleDbType.Int32)
    p_SolutionID.Direction = ParameterDirection.Input
    p_SolutionID.Value = arrSolutionID
    cmdUpdateSolutionStatus.Parameters.Add(p_SolutionID)
    'Add InOrOut array as parameter
    Dim p_InOrOut As New OracleParameter("InOrOut", OracleDbType.Int32)
    p_InOrOut.Direction = ParameterDirection.Input
    p_InOrOut.Value = arrInOrOut
    cmdUpdateSolutionStatus.Parameters.Add(p_InOrOut)
    'Add TimePeriod array as parameter
    Dim p_TimePeriod As New OracleParameter("TimePeriod", OracleDbType.Int32)
    p_TimePeriod.Direction = ParameterDirection.Input
    p_TimePeriod.Value = arrTimePeriod
    cmdUpdateSolutionStatus.Parameters.Add(p_TimePeriod)
    'Open connection
    cnnORACLE.Open()
    'Run stored procedure
    cmdUpdateSolutionStatus.ExecuteNonQuery()
    'Tidy up
    cmdUpdateSolutionStatus = Nothing
    cnnORACLE.Close()
    Catch ex As Exception
    WriteLog("Subroutine UpdateSolutionStatusUsingArrays:" & ex.Message.ToString)
    strState = "Error"
    'Update Run Status to show error has occurred
    cnnORACLE.Close()
    UpdateRunStatusORACLE(7)
    End Try
    End Sub
    When the routine tries to run cmdUpdateSolutionStatus.ExecuteNonQuery() I get the error message:
    Unable to cast object of type 'System.Int32[]' to type 'System.IConvertible'.
    I have tried all sorts of variants of the code but with no success. The arrays are being set up correctly. Anyoneone know what I'm missing?
    Stewart

    Try declaring the arrays as OracleNumber datatype instead of Integer. I've had this issue before, and I believe this is what I did to solve the problem.

  • Arrays.toString problem

    Hello,
    I'm trying to print out the values of an integer array using the method toString(int a[]) of the Arrays's class. While doing it, I encounter the following error:
    Array.java:17: toString() in java.lang.Object cannot be applied to (int[])
              System.out.println (Arrays.toString(a));
    The source code is the following:
    import java.util.*;
    class Array{
         public static void main (String[] args){
              int[] a = new int[10];
              Random rand = new Random ();
              for (int i=0; i<a.length; i++)
                   a= rand.nextInt(10);
              Arrays.sort(a);
              System.out.println (Arrays.toString(a));
    Hope someone can help me!
    Thanks a lot.
    Gabriel

    sabre150 wrote:
    Sounds like an interesting little project. I've been trying to write an article on cross platform/language encryption so I've been doing little bits of C/C++/C#/Python/PHP/JNI . I don't find writing easy so the task is turning out to be a lot bigger than I anticipated.
    I have fond memories of electric shock treatment. Having trained as an Electrical Engineer I spend the first 4 years of my working life trying to kill myself. Nearly succeeded twice. Now I long to get back to the sort of breadboards that you are working on but no real chance. I would like to create a playing card dealing system but my hardware knowledge is so out of date that I don't really have a hope.Stay far away from hardware; I once fell for it and designed a little logic game in hardware (Nim); I got it all together, including the total costs (just a few bucks) and happily went to the electrickery store. They laughed at me and told me about power supplies and debouncing switches and buffers for the LEDs and what have you. After an hour I stood outside again after having spent almost 200 bucks. I started soldering and I soldered and soldered; in the end I had a big blob of spaghetti and it didn't work. I started all over again and I ended up with an even bigger blob of spaghetti that didn't even fit anymore in the little box I bought. But it worked.
    I had fun for almost 10 minutes until my little rabbit (I kept it as a cat) saw it, chewed on the spaghetti blob and it never worked again ... so far for hardware; don't go there.
    kind regards,
    Jos ;-)

  • Can i use array.count in line?

    All,
    I have one small oracle program that take a ',' separated string as an input
    and assigns the individual string to a nested table.
    I am wondering if I can directly use array.count in my sql below
    instead of assigning the count of the array 1st and then
    using it.
    l_cause_codes_array := util_pkg.tokenize_string(p_cause_codes_csv, ',');
    l_count := l_cause_codes_array.count;
    My current sql:
    delete from po_complaint_cause p
    where p.po_number = p_po_number
    and p.comp_code = p_comp_code
    and l_count > 1;
    I would like to do something like:
    delete from po_complaint_cause p
    where p.po_number = p_po_number
    and p.comp_code = p_comp_code
    and l_l_cause_codes_array.count> 1;
    I just want to reduce one context switch if possible.
    Thanks.

    Hi,
    did it give an error? Did you try? But it is possible.
    But why not the next code:
      l_cause_codes_array := util_pkg.tokenize_string(p_cause_codes_csv, ',');
      if l_cause_codes_array.count >1
      then
        delete from po_complaint_cause p
        where p.po_number = p_po_number
        and p.comp_code = p_comp_code
      end if;Do only the delete if it is bigger than 1, that is I think the fastest switch.
    Herald ten Dam
    http://htendam.wordpress.com

  • How to use array of Point Class

    I use Point class as array. I already create that. However I can't access to setLocation.
    Ex.
    Point myPoint[] = new Point[10];
    myPoint[0].setLocation(10, 2);
    It has a error.
    Please Explain me.

    DeltaGeek wrote:
    BalusC wrote:
    Or use [Arrays#fill()|http://java.sun.com/javase/6/docs/api/java/util/Arrays.html]. Point[] points = new Point[10];
    Arrays.fill(points, new Point());
    That doesn't do what you think it does, unless you want your array to contain 10 references to the same Point object.The OP has received a good answer, I believe. So it's worth risking diverting this thread into the weeds by pointing out that if Java had closures then BalusC's code could be modified to work.

  • Stack ADT using array

    Hi everyone, I posted a similar question earlier and thought I got the response I wanted but I keep running into problems.
    I'm looking to make my own version of the stack ADT using arrays (or arraylist).
    I have created my own isEmpty() method. Here is part of my code:
    public interface StackADT<T> {
         void push(T element); // adds an element to the stack
         T pop(); // removes an element from the stack and returns it
         boolean isEmpty(); // returns true if the stack is empty and false otherwise
         T peek(); // returns top element from the stack without removing it
         void truncate(); // truncates the stack to the exact number of elements
         void setExpansionRule(char rule); // sets expansion to either doubling or increasing by 10 elements
    public class Stack<T> implements StackADT<T> {
              private T[] array;
              int index = 0;
              public Stack(){
                   this.array = (T[]) new Object[50];
              public boolean isEmpty(){
              if (index == 0){
                   return true;
              return false;
               public T pop(){
                    if(Stack<T>.isEmpty()){  //ERROR
                     throw new EmptyStackException("Stack is empty");     
    }I'm trying to use my isEmpty() method (also part of the stack class) inside other methods like pop(). Problem is it says: "T cannot be resolved to a variable, Stack cannot be resolved to a variable". I also tried Stack.isEmpty(), but it doesn't work. I'm really confused. Any suggestions?
    Edited by: Tiberiu on Mar 1, 2013 6:38 PM

    >
    Hi everyone, I posted a similar question earlier and thought I got the response I wanted but I keep running into problems.
    I'm looking to make my own version of the stack ADT using arrays (or arraylist).
    I have created my own isEmpty() method. Here is part of my code:
    >
    No - you haven't. There is no 'isEmpty' method in the code you posted.
    We can't debug code that we can't see. You haven't posted any interface and you haven't posted anything that calls any of the limited code that you did post.
    You did post code that tries to call the method on the class instead of an instance of the class.
    if(Stack<T>.isEmpty()){ 

  • Using arrays with formulas

    I'm having trouble getting my arrays to work in the formula that I need to use to calculate a monthly mortgage payment, which is what I need to do. I'm supposed to use arrays to store three different term year amounts and three different interest rates, and then display the monthly payment and other info for each amount. Can someone help with this? I keep getting errors that say "cannot use operator / or * with double[]". Here is my code:
    class PaymentArray {
         public static void main(String[] arguments) {
              double amount = 100000;
              int[] term = {7, 15, 30};
              double[] rate = {.0535, .055, .0575};
              double payment = (amount*(rate/12))/(1-(Math.pow(1/(1+(rate/12)),(term*12))));
              for (int i = 0; i < term.length; i++) {
                   for (int j = 0; j < rate.length; j++) {
                        System.out.println("If the initial loan amount is " + amount);
                        System.out.println("and the length of the term is " + term + " years");
                        System.out.println("and the monthly interest rate is " + rate);
                        System.out.println("The monthly payment will be " + payment);
    }Any help would be greatly appreciated. Thanks!!! :-)

    That all worked really well, thanks so much!!!
    The only problem I have now is, instead of calculating the payments at 7 years/5.35%, 15 years/5.5%, and 30 years/5.75%, it's calculating them for 7 years at 5.35%, 5.5%, and 5.75%, 15 years at 5.35%, 5.5%, and 5.75%, and so on. I don't need it to do all of that, I need the years to correspond to the correct interest rate. How can I change that? Thank you so much. Here is my new code:
    class PaymentArray {
         public static void main(String[] arguments) {
              double amount = 100000;
              int[] term = {7, 15, 30};
              double[] rate = {.0535, .055, .0575};
              for (int i = 0; i < term.length; i++) {
                   for (int j = 0; j < rate.length; j++) {
                        System.out.println("If the initial loan amount is " + amount);
                        System.out.println("and the length of the term is " + term[i] + " years");
                        System.out.println("and the monthly interest rate is " + rate[j]);
                        double payment = (amount*(rate[j]/12))/(1-(Math.pow(1/(1+(rate[j]/12)),(term*12))));
                        System.out.println("The monthly payment will be " + payment);

  • How to use array?I am a newer   ------:(

    In C language I can use array this way:
    char array[10][20];
    fread(array[1],20,1,fp);
    but in java,what to do?
    char array[][]=new [10][20];
    and the code below will cause an error:
    binstream.read(array[1]);//error line
    pls help me and tell me what to do,thank you very much

    Hi evilstar007!
    1st) There aren't unsigned primitives in Java, all primitives are signed.
    2nd) The loop in previous message will read an entire line filling the buffer without length contraints. If there are n^z then it will read n^z "chars". This is is for text but I know there is a special one as you need, for bytes (primitive byte). You can also retrieve the bytes from stream:
    data = new byte[dim];
    inp.read(data);
    I'm not sure about, there are a lot of methods and classes.
    You pretend to read from stream and fill the contents of RomBanks array with length 32768L ok ?
    Read the entire line and retrieve bytes.
    Since you are a C programmer will be easy to understand Java.
    Best Regards!

  • Using array create JLabel

    i have one problem about using addKeyListener, i'm using array to create JLabel but once i've compile it, it came out a message as i shown, so where is my problem, hope someone can fix it for me and explain it for me, thank you
    ---------- Capture Output ----------
    "C:\Program Files\Java\jdk1.6.0_03\bin\javac.exe" Login.javaLogin.java:78: not a statement
    inputTextName[1]KeyPressed( event );
    ^
    Login.java:78: ';' expected
    inputTextName[1]KeyPressed( event );
    ^
    2 errors
    Terminated with exit code 1.---------- Capture Output ----------
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Login extends JFrame
         //JLabel[] lblName = {"lblName1","lblName2"};
         JLabel[] labelName;
         //JTextField[] txtfldName = {input1,input2};
         JTextField[] inputTextName;
         //JLabel[] array = new JLabel[veryLargeNumber];
         JButton[] btnName = new JButton[3];
    public void userInterface()
         this.setBackground(Color.blue);
         this.setTitle("Log in");
         this.setSize(285,130);
         this.setVisible(true);
         Container contentPane = getContentPane();
         contentPane.setLayout(null);
         labelName[0] = new JLabel();
         labelName[0].setText("ID: ");
         labelName[0].setBounds(16, 16, 130, 21);
         this.add(labelName[0]);     
         inputTextName[0] = new JTextField();
         inputTextName[0].setText(" ");
         inputTextName[0].setBounds(50, 16, 150, 21);
         inputTextName[0].setHorizontalAlignment(JTextField.LEFT);
         this.add(inputTextName[0]);
         labelName[1] = new JLabel();
         labelName[1].setText("Password: ");
         labelName[1].setBounds(16, 48, 104, 21);
         this.add(labelName[1]);
         inputTextName[1] = new JTextField();
         inputTextName[1].setText(" ");
         inputTextName[1].setBounds(50, 48, 150, 21);
         inputTextName[1].setHorizontalAlignment(JTextField.LEFT);
         this.add(inputTextName[1]);
         btnName[0] = new JButton();
         btnName[0].setText("login");
         btnName[0].setBounds(120,80,65,20);
         this.add(btnName[0]);
         btnName[1] = new JButton();
         btnName[1].setText("exit");
         btnName[1].setBounds(190,80,65,20);
         this.add(btnName[1]);
         inputTextName[1].addKeyListener(
             new KeyAdapter() // anonymous inner class
                // method called when user types in cartonsJTextField
                public void keyPressed( KeyEvent event )
                  inputTextName[1]KeyPressed( event );
             } // end anonymous inner class
          ); // end call to addKeyListener
    //call function
         public Login()
              userInterface();          
         public static void main (String args[])
              Login application = new Login();
               application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
         }Edited by: slamgundam on Oct 24, 2007 11:48 PM

    slamgundam wrote:
    the purpose is try to get the text in the inputTextField
    inputTextName[1].addKeyListener(
        new KeyAdapter()
             // method called when user types in cartonsJTextField
             public void keyPressed( KeyEvent event )
                   String str = inputTextName[1].getText();
                   System.out.println(str);
    );

  • Can I use Array Binding with a ExecuteDataSet or ExecuteReader methods?

    I want to use Array binding with selects. From the examples that I see so far it seems like everyone is showing the ExecuteNonQuery method. I wonder if I can use this functionality with a regular query that returns ref cursoros.
    Andrzej

    what is the error you recieve?

  • How to use String toString?

    hey guys,
    I've 2-D array and i would like to printout using String toString method. I'v used that method to printout non-array values but I really don't know how to display 2-D array using the String toString method. Can someone please help me? thanks in advance!

    I do not understand your question. Please post
    whatever code you have and indicate where you are
    stuck.I'm sure you're aware of the String toString method which is often used to display the output in different classes without the main method.
    I've following code:
    public static int bingoCard [][] = new int[SIZE][SIZE]; 
    public BingoCard()   {
            Integer ran = 0;
            for (i = 0; i < SIZE; i ++) {
                 if (i == 0) {
                    min = 1;
                    max = 15;
                } else {
                    min = max + 1;
                    max += 15;
    //             System.out.println("Min: " + min + " " + "Max: " + max);
                // generate all 15 balls in this range
                for (j = min; j <= max; j++) {
                    bC.add(new Integer(j));               
    //             // randomize the 15 balls           
                for (j = 0; j < SIZE; j++) {
                    while (bingoCard[i][j] == 0) {
                        ran = (Integer)bC.removeRandom(); // get Integer object back
                        if (max <= 15 && (ran.intValue() >= 1 && ran.intValue() <= 15))
                            bingoCard[i][j] = ran.intValue();              
                        else if(max <= 30 && (ran.intValue() >= 16 && ran.intValue() <= 30))
                            bingoCard[i][j] = ran.intValue();           
                        else if(max <= 45 && (ran.intValue() >= 31 && ran.intValue() <= 45))
                            bingoCard[i][j] = ran.intValue();              
                        else if(max <= 60 && (ran.intValue() >= 46 && ran.intValue() <= 60))
                            bingoCard[i][j] = ran.intValue();             
                        else if(max <= 75 && (ran.intValue() >= 61 && ran.intValue() <= 75))
                            bingoCard[i][j] = ran.intValue();
    //                 System.out.println("Numbers in the card: " +  bingoCard[i][j]);
            bingoCard[2][2] = 0;       
    Now, i want to dipslay the bingoCard[][] using following method
    public String toString () { // return that array } instead of using following method which displays it for now
    public static void display () {
            for ( i = 0; i < SIZE; i++) {
                 System.out.print(" "+ columnTitles[i] +"   ");
            System.out.println(); 
            for (i = 0; i < SIZE; i++) {  
                for (j = 0; j < SIZE; j++) {               
                    System.out.print(" "+bingoCard[j] +" ");
    if (bingoCard[j][i] < 10)
    System.out.print(" ");
    System.out.println();
    Any help would be really apperciated. =]

  • Parameter Formula Error: This array must be subscripted

    We are using Crystal XI.  I've tried searching the help files in Crystal and have tried to find similar posts in the forum.  This is the first time I've written a parameter formula that includes two different date field references.  Any help would be greatly appreciated.
    I am receiving the error "This array must be subscripted.  For example: Array <i>." in the following parameter formula:
    {TRACKING_FILE.f463#loan_status} <> "Z" and
    {TRACKING_FILE.REGION_ID} <> "CORRES" and
    {TRACKING_FILE.f415#approval_date} < {?Approval Date Less Than} and
    {TRACKING_FILE.f463#loan_status} in ["W","R"] and
    {TRACKING_FILE.f428#reject_withdrawn_date} > {?Rejected Withdrawn Date}

    I believe the curser was stopped right before the "Rejected Withdrawn Date" in the formula.  I've rewritten the entire formula as follows and I'm not receiving any errors. 
    {TRACKING_FILE.f415#approval_date} < {?Approval Date Less Than} and
    {TRACKING_FILE.f428#reject_withdrawn_date} > {?Rejected Withdrawn Date After } and
    {TRACKING_FILE.f426#disbursement_date} > {?Closed Date Greater Than }
    Thanks for your help.

Maybe you are looking for

  • How do I remove the grid map over an object when working in 3D?

    I am working through Adobe's Photoshop CS6 Classroom in a Book, Section 12 - Working with 3D Images. So far I have found it all fairly straight forward and very useful. I am at a point where I am applying textures and materials to my objects, however

  • Satellite Pro L - Upgrade from Vista to Windows 7 possible?

    Does anyone know if the Satellite Pro Recovery disc (Vista) qualifies as a basis for upgrading to Windows 7 using a Microsoft Upgrade Edition disc? Or is the full retail new version needed?

  • I have pinkish and yellowish tint and stripes on my iphone 4s screen.

    I have pinkish and yellowish tint and stripes on my iphone 4s screen. Should I take it to the service or will it get better by itself?

  • Memory leak with Swing application

    My application uses more and more memory as I use it. However, if it is working like I think, it is not creating more objects and has no reason to use more memory. When the application is minimized a lot of that memory is freed up. Does anyone know w

  • Error When Creating Deployable Client Proxy

    I've created a WSDL file from the XI Integration Directory (Tools--> Define Web Service). I then tested this with XMl Spy and VB.NET. They worked fine. I then used NWDS (SP13) to create a deployable client proxy. When building the client definition N