Regarding basic Java

hello!!!!!!!!!!!!!!
i have a doubt .if u pls clarify it
the problem is when i want to initialise the elements of array in the class , i get error message
like this------------------------------
public class Dataman {
String[] aa= new String[10];
aa[0] = "bb";
but if i want to initialise in constructor no error messge is shown
public class Dataman {
public Dataman(){
String[] aa= new String[10];
aa[0] = new String("qq");
why it is so????????????????

The initializer allowed at the declaration of a variable is limited to a simple single assignment. If you need to do any fancier stuff, you need to put that into a code block. The appropriate place for such code is the constructor.
Initializing an array is also possible by an initializer. You, however, have to choose between specifying the length of the array explicitly, in which case the whole array is nulled, or an initializer, which implicitly specifies the length of the array:
String[]  s1 = { "ab", "cd", "ef" };   // an array of size 3, initialized with the provided values; syntax restricted to initializers
String[]  s2 = new String[] { "ab", "cd", "ef" };   // dito, but syntax also good in ordinary code
String[]  s3 = new String[7];                           // an array of size 7, initialized with nulls; good for initializers and ordinary code

Similar Messages

  • Sap basic java libs, JMON, JCO

    Hi,
    Iam applying patch 27 for the portal ep6 sp2. the current patch is ep6 sp2 patch3 with j2ee pl 19.
    Now first iam doing patch 4 for ep6 sp2 and then upgrading to patch 27.
    My question now is for upgrading to patch 4 what version of java libs, jmon and jco i should maintain and later for patch 27 what version of basic java lib, jmon and jco i should maintain.
    The patch4 document says to update basic javalibs, jmon and jco to the latest available one.
    The latest available patches are
    basic java lib - patch 18
    jmon - patch 19
    do anyone know how to do this. any documents are notes available ???
    Thanks for your help in advance
    regards
    Moses

    Hi Moses,
    here is what to you have to do:
    1. Patch the Software Delivery Manager (SDM) to the newest Patch Level (PL 14) - as described in SAP Note 532892
    2. Patch the J2EE Engine to the newest available patch (PL 30) - as described in SAP Note 738921
    3. Patch SAP Basic Java Libs 6.20 to Support Package 18 - as described in SAP Note 544979
    Make sure IRJ service is stopped as mentioned in the thread Basic Java Libs 16
    4. Patch JMON to Patch Level 19. Installation (path were to copy the files) is described in SAP Note 657143. Unfortunately this note is not released. If you don't have a user to see the note, here is in short what you have to do:
    - unzip the archive: "sapcar -xfv JMON_19*.SAR"
    - copy file jmonapi.jar to the following directories:
         - ...j2ee_<Instance_Nr>adminlib
         - ...j2ee_<Instance_Nr>admin     ools
         - ...j2ee_<Instance_Nr>clusterdispatcheradditional-lib
         - ...j2ee_<Instance_Nr>clusterserveradditional-lib
         - ...j2ee_<Instance_Nr>clusterstateadditional-lib
         - ...j2ee_<Instance_Nr>clusterserverservicesfileworklibs
         - ...j2ee_<Instance_Nr>clusterserverstatefileworklibs
    - copy file jmon.dll and sapccmsr.exe to the directory:
         - ...j2ee_<Instance_Nr>os_libs
    5. If needed, patch SAP Java Connector to Service Release 2.0.10 - as described in SAP Note 682686 and the there mentioned installation guide.
    6. Now you can go on patching the Portal first to Patch 4 and than to Patch 27 as described in the installation guides.
    Hope this helps,
    Robert
    PS: Please consider rewarding points to people like Dominik (and me) , who are spending a lot of their time to give helpful replies like in this thread: cross domain SSO-EP6

  • Regarding Sun Java System Application Server Issue with JVM

    Regarding Sun Java System Application Server Issue with JVM
    Hi
    I have installed SJSAS9.1 on solaris system. I m trying to deploy war file which i compiled in windows enviorment by jdk1.5.0_05. Every time i got the following error :
    type Exception report
    message
    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP
    PWC6199: Generated servlet error:
    [javac] javac: invalid target release: 1.5
    [javac] Usage: javac
    [javac] where possible options include:
    [javac] -g Generate all debugging info
    [javac] -g:none Generate no debugging info
    [javac] -g:{lines,vars,source} Generate only some debugging info
    [javac] -nowarn Generate no warnings
    [javac] -verbose Output messages about what the compiler is doing
    [javac] -deprecation Output source locations where deprecated APIs are used
    [javac] -classpath Specify where to find user class files
    [javac] -sourcepath Specify where to find input source files
    [javac] -bootclasspath Override location of bootstrap class files
    [javac] -extdirs Override location of installed extensions
    [javac] -d Specify where to place generated class files
    [javac] -encoding Specify character encoding used by source files
    [javac] -source Provide source compatibility with specified release
    [javac] -target Generate class files for specific VM version
    [javac] -help Print a synopsis of standard options
    note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1 logs.
    I have cheked jvm version on both system the only difference is :
    Solaris points to jdk 1.5.0_09
    Windows point to jdk1.5.0_05
    Even i tried to run blank jsp also but again i got the same error.
    Can any help me to sort out the problem or give me any idea so i can do something by my own.
    Thanks in Advance
    Gagan

    Do you have ANT installed and available?
    Thanks,
    Kedar

  • 4 basic java questions..

    ok so I already learned Java last year (in grade 11), but my teacher didn't really teach anything, we learnt everything by ourselves from the API... so theres a lot of things I actually don't understand, but for now I want to ask 4 basic questions:
    1. What does static mean?
    2. Why would u "final" a constant variable? ie. If you have a variable called SIZE which is set to 5, so if u want it to be a constant, just never change its value. But what does the keyword final do to it?
    3. What's super? I see it sometimes, and my teacher showed us in the applet exampls to use super.paint(g) or somethign like that for the paint method, but I never use that because I noticed it works fine without it..
    4. Whats a question mark? I saw a game that was made in java and it had a lot of places where it had a question mark , which was part of the syntax. For example,
    int j1 = i != 0 ? i - 1 : 199;
    OR
    JUMPVEL = (fSuperSlime) ? 65 : 31;
    I really don't understand these lines...
    feel free to answer any of these questions...

    wow cool...thanks.. that question mark thing is nice
    saves a few lines..
    now, about super, so u mean u can access the parent
    class's variables?Variables, methods, constructors, if the access level is such that it's allowed.
    This will be covered in any tutorial or text though.
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java.
    James Gosling's The Java Programming Language. Gosling is
    the creator of Java. It doesn't get much more authoratative than this.

  • Basic java comparision

    Hi..
    I have a basic JAVA problem..can anyone help on this.
    I have a constant declared in a EMPConstanta.java
    public static String HISTORICAL = "historical";
    In another java class..i need to compare 2 strings..
    String statusType = req.getParameter("historical"); //this vale comes from JSP hidden parameter and the value of statusType is historical
    Now I want to compare with constant vale.. and I am doing like this..
    if(statusType.equals( ASMConstants.HISTORICAL)){
    statusType = ASMConstants.CURRENT;
    Problem is both the values are historical�but it is not entering to if condition..any suggestions

    http://forum.java.sun.com/thread.jspa?threadID=5203921&tstart=0
    avoid multi post

  • Berkeley DB master-slave replication basic java code example

    Hi,
    I am new user of berkeley db and I have limited knowledge of Java programming. Can someone help me with basic Java example code of how to do master-slave replication without elections.
    Thanx,
    Jani

    Hello,
    Please clarify a few points about your program:
    1. What platform and Berkeley DB version are you using?
    2. Are you planning on using the replication framework
    or base replication API for your application?
    3. When you say you want replication without elections,
    what exactly does that mean. For example, if you are using
    the replication framework elections are held transparently
    without any input from your application's code. In this case,
    DB will determine which environment is the master and which
    are replicas. Is that what you are thinking about or
    something else?
    Thanks,
    Sandra

  • Making some basic Java games

    Can anyone help on how to make some basic java games for my website if you could that would be helpful
    thanks,
    Louie

    Well, first of all you program the Framework, add Graphics / sounds / Data , then you put it in your HP - There you are!

  • Knight tour programming with only basic java

    i had this assignment from school which ask us to create a program to calculate how many posssibilities to complete knight's tour from a position using basic java and not using applet. So far i can only create an incomplete program which can only go a speccific way and is also incomplete. i am trying to understand the jaava applet type of knight tour program but got too confused as i have just started learning this. Please help me with this.
    here's my code:
    public class uk16638_a3{
         public static void main(String[] args){
         int horizontal[] = {2,1,-1,-2,-2,-1,1,2};
         int vertical[] = {-1,-2,-2,-1,1,2,2,1};
         int chessBoard[][]=new int[8][8];
         int move, currentRow = 0, currentCol= 0, move_count = 0, new_vert, new_horz;
    for(int i=0; i<8; i++)
         for(int j =0; j<8; j++)
              chessBoard[i][j] = 0;
    chessBoard[0][0] = 1;
    do{
    for(move=0;move<8;move++){
    new_vert = currentRow + vertical[move];
    new_horz = currentCol + horizontal[move];
    if ( (new_vert>=0) && (new_vert < 8) )
    if( (new_horz>=0) && (new_horz < 8) )
    if( chessBoard[new_horz][new_vert]==0 ) {
    chessBoard[new_horz][new_vert] = 1;
    move_count++;
    currentRow = new_vert;
    currentCol = new_horz;
    }}}while(move<8);}}

    Sorry with the inconvenience cause i am new with this forum so i am causing many problems to all of you. here's the full code i put but i would really like to ask someone to teach me on creating a backtrack and let the knight moves following a different sequence from the one i already set.
    public class uk16638_a3{
    public static void main(String[] args){
    //the movements of a knight horizontally and vertically
    int horizontal[] = {2,1,-1,-2,-2,-1,1,2};
    int vertical[] = {-1,-2,-2,-1,1,2,2,1};
    int chessBoard[][]=new int[8][8];
    int move, currentRow = 0, currentCol= 0, move_count = 0, new_vert, new_horz;
    //setting all elements in the array to 0
    for(int i=0; i<8; i++)
    for(int j =0; j<8; j++)
    chessBoard[i][j] = 0;
    //the knight starts here
    chessBoard[0][0] = 1;
    //using do while loop, i try to move the knight following the sequence i had already set in the array above. But because its moving at the same direction all the time, it gets stuck.
    do{
    for(move=0;move<8;move++){
    //setting the new coordinates for it to move to
    new_vert = currentRow + vertical[move];
    new_horz = currentCol + horizontal[move];
    if ( (new_vert>=0) && (new_vert < 8) )
    if( (new_horz>=0) && (new_horz < 8) )
    //new position check if its already occupied or not, if occupied it will move on to the next part of the move sequence i set
    if( chessBoard[new_horz][new_vert]==0 ) {
    chessBoard[new_horz][new_vert] = 1;
    move_count++;
    //current coordinate of the new knight position
    currentRow = new_vert;
    currentCol = new_horz;
    }}}while(move<8);}}
    Edited by: Mikki88 on Mar 2, 2009 1:53 AM

  • Basic Java Class with prints records out of the DEPT table

    Can some one show a basic java class which will query the DEPT table, and print them out?

    Nagarjuna,
    the Oracle DBMS JDBC Developer's Guide is full of code examples.
    http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/toc.htm
    --olaf                                                                                                                                                                                                                                                                                                                       

  • Basic Java Sound Example.

    Hi,
    Can some one give me a basic java sound application( not applet ) to play a wav file.
    Thanks a lot.
    zia

    I did this search
    http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2Bplay+%2Bsound+%2Bwav+%2Bapplication&col=jdc&x=14&y=10
    looks like the answer should be there somewhere

  • Need help with a basic java thing..

    Sorry, just started java a few weeks ago and i'm having trouble figuring out how to do something.
    I wanted to know how to make this work. It cant be more than 6 characters in length and of those six characters, the first two have to be letters only, followed by a dash (-) and then three numbers. EG: ab-234 or gf-643...
    Im using it as a serial number generator type thing, thats only one part of the entire program, but I cant figure it out.
    Just need the most basic way to do that if anyone could help! been looking for hours in a couple java books i have and dont know where to look or what to look for!!
    Any help figuring out the code for that would be great! Here's what I have so far and how i need the rest to be implemented! Thanks! PS: using TextIO
    <code>
    String itemNum1
         itemNum1 = new String ( " Enter Item Number(AB-123): " );
         TextIO.put("\n" + itemNum1);
         itemnum = TextIO.getlnString();
    </code>

    Oh hey sorry, i figured the bit of text i put in there
    would be enough. I basically need a user to enter the
    information, but i just need to know (or get a hint)
    of how to prevent them from entering an invalid
    number/serial code type thing in regards to the
    parameters that I need met. (such as no more than 6
    chars, but alternating numbers/letters). I presume I
    use the char and not the getlnString command but
    nonetheless im still stuck as to how I'd manage that.
    Do i need to code each character seperately? (such as
    letters by themselves, then another prompt to enter
    the numbers??) or is there a way to get it all in one
    go?
    Thanks for any advice! oh and Sorry for the bad
    wording in my question :P.
    You could read the String from console using something like
    public static String readWord()
       {  int ch;
          String r = "";
          boolean done = false;
          while (!done)
          {  try
             {  ch = System.in.read();
                if (ch < 0
                   || java.lang.Character.isSpace((char)ch))
                   done = true;
                else
                   r = r + (char) ch;
             catch(java.io.IOException e)
             {  done = true;
          return r;
       }you would have to modify it according to your needs and after that you could use the String API to confirm if the user has entered it right or not. If not you could ask him to do that again

  • Basic Java Card/Card reader application question...

    Hello all,
    I have a basic question regarding java card applications. Do you always require a host application(on some PC/workstation server) to send and receive data from the java card (through the card reader using any of the available interfaces like OCF etc) or can you have a stand alone card reader application that interacts with java cards inserted into the reader?
    For example..in a mass transit application, you have a reader that reads an e-purse smart card that is swiped and does the necessary deduction of the fare from the card. In this case, where does the host application reside (there is no other host system involved other than the reader here? ) How is this done? Does the card reader carry the necessary code to interact with cards?
    Any information is greatly appreciated.
    Thanks for the time.
    Regards,
    Ajay

    Documentation is provided by the terminal vendors. Just think of it like this, there are drivers that read the card, but don't know what to do with the data without some form of middleware to process it.

  • Basic Java programs.....Please read

    I just need some links to where i can dowload some some basic toolboxes and kits. (to make basic programs and practice)
    Please porvide links, i've been searching. Since I'm so unfamiliar with Java programming i haven't has much luck.

    JSE 1.5 download: http://java.sun.com/javase/downloads/index.jsp
    vim download: http://www.vim.org/download.php
    kind regards,
    Jos

  • Basic Java Concepts

    I'm a Java novice, trying to learn it along with Jdeveloper side by side. My learning of the Java fundamental concepts led to the below understanding, please see if my understanding is not correct in any way.
    The fundamental concept with Java is a CLASS, whose feature are its state and behaviour. The state of the class is stored in the definition of the class itself via ATTRIBUTES or in lay man's language VARIABLES. These attributes can be static, public, private or protectd.
    The behaviour of a class is stored via METHODS within the definition of a class. METHOD is nothing but a block of code performaing a certain action.
    A good example of a CLASS's state a behaviour can be a stock. A stocks state is available via its ticker symbol, price of the stock, and the date i.e. on a given date, a given stock has a particular price. So there are 3 attributes.
    Now METHOD in the context of the above example is a means to capture the ever changing state of the above 3 attributes.
    In short attributes or fields ( defined via declaration of variables inside the class) capture the state of an object, where as its interaction with the world external to the object captured by METHOD.
    These 3 attributes are common to thousands of stock's in the outside market, so a common class called STOCK can be created to capture the state and behaviour of thousands of stocks. The same class can be called at the same time to capture the behaviour of N number of stocks. When a class is called as explained, each such call is called an INSTANCE of the CLASS. An OBJECT is an instance of SUCH a class.
    Similar to CLASS is INTERFACE. A given class can only call the attributes and methods from one another class. If a class needs to inherit from more than one another class then it is accomplished via an INTERFACE. An Interface contains only the spec of the methods from other classes and not the entire piece of code for he method itself. The methods that are declared in the interface are implemented in the classes to which they belong to.
    A PACKAGE in turn is a collected of CLASSES and INTERFACES. A PACKAGE helps in keeping the code oraganized and grouped by the functionaliy it delivers.
    A Class can in turn be either a SUPERCLASS or a SUBCLASS. In our given example CLASS, there are some stocks which offer OPTIONS and some which do not. In order to cover that behaviours we will like to create sub class called STOCSKWITHOPTIONS, which will then refer to STOCK class to inherit the attributes and methods from that class. In this case STOCK is the SUPERCLASS, and STOCKOPTIONS is the SUBCLASS.
    Thanks in advance

    Nagarjuna,
    there is an excellent tutorial series from Sun for basic and advanced Java features. It contains a lot of examples and explains every concept. You even download the tutorials.
    See http://java.sun.com/javase/reference/tutorials.jsp
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Regarding the Java version for  installation of ECC6.0

    Hi frnds
    When i tried to install ECC6.0 abap + java system with version j2sdk-1_4_2_13-windows-i586-p.exe,  igot stuck up with errors.My dear friends please suggest me which version should i use and from where to down load.Please help me out.
    From
    Siva

    Hi Siva,
    perhaps it is better to aks your question at one of these
    forums
    Java Development
    SAP NetWeaver Application Server
    SAP on Microsoft Windows
    Regards
    Bernd

Maybe you are looking for

  • Simple Inbound ABAP Proxy doesn't work in my new PI 7.1 EHP 1 SP3 ?

    Hi, I just installed and configure new PI 7.1 EHP 1 SP3 and i tried some simple abap proxy but seems like doesn't work. Please advise what is missing base on my simple abap code below : METHOD zpi711ii_si_syn_in_aaeproxy~si_syn_in_aaeproxy. **** INSE

  • Creating UI iview in web dynpro

    How do i go abt in creating an iview UI in web dynpro that interfaces with Trex . basically i have set of documents that need to be searched and the iview should be called Advanced search which fetches the data from the indexed documents.

  • Bank details in the vendor mastr data is to be suppressed

    I have requirement to supress all the fields in the vendor master data other than the address. I have created the separate Vendor account group and I have suppressed all the fields in the system. Still I am getting the Bank details in the vendor mast

  • Backup Disk Read Only

    Hey, Jus got my new MacBook Pro couple of weeks ago.. and trying to use the time machine for backup and it seems to always end up with an error.. it successfully finishes the initial backup.. once the backup drive is ejected and reinserted it becomes

  • Error in EDI Partner or partner profile partner no while notification close

    Hi All, When trying to close notification the system provides error message u201CError in EDI Partner or partner profile partner number".  The Relevant transaction code is QM02. EDI relevant partner profiles are maintained in table EDPVW which has en