Need opinions about using methods in-line

Hello fellow SDNers,
I have this piece of code where i use functional method as operand, string formatting options in-line et al. A friend of mine says it's not too descriptive.
  cl_demo_output=>display_text( |Laufzeit: { lcl_calc_laufzeit=>main(
                                                 im_date_from = p_begda
                                                 im_date_to   = p_endda )-count ALIGN = LEFT } Monat(e)| ).
Is Too-little is just too confusing?
I like in-line data declarations, functional methods because i feel they are more intuitive.
What are your ideas/opinions about it?
BR,
Suhas

Hi Suhas,
when i was starting with C-programming, i was impressed by what you could achieve with just so little of actual coding.
I thougt it was quite cool, when I managed to squeeze whole programs into just a few lines, using heavily nested ternary operators and for-loops.
Well, they did what they where meant to do, but when after a while i had to alter one only gradually, it took me some time to rethink, what i myself had created not so long ago.
Imagining how someone else would try to follow my line of thought, i came to the conclusion, that it was not so desireable, to squeeze the last bit of efficiency out of the characters that built the source-code, but that it could be far better, to enfold it, make it bigger, even less elegant, but allthemore easier to understand.
Why do i tell you this?
I seem to recognize a bit of the fascination, i felt myself, in your code sample. Letting you beeing carried away by possibility alone, does not necessarily lead to the best results on the long run.
Back to your question - i'm afraid, your friend was right.
You can do better, without loosing to much.
Truth be told, i haven't done too much in the line of string templates and nested method calls yet.
I have to admit, i'm challenged even to follow, what your sample exactly does. Nevertheless, i will dig in and discover whatever it may provide for me .
Best regards - Jörg

Similar Messages

  • I also need information about use the ProConnect(r) Integ...

    I also need information about use the ProConnect(r) Integrated KVM 2-Port Switch to connect a Mac G4 and a PC anyone help
    software reviews editor

    I suggest you to go to linksys website & it will give all required information ,,,
    Or you can try this link ....

  • I'd like to read  your opinions about  a method.

    Hi everyone.
    Just want opinions.
    If someone tells u that its only going to use the method , what kind of asserts would u use?
    They told me that , i must use asserts, but i already have an assert in the main (which is not going to be used by them)
    They have their own main to test.
    So do i use the same assert in the method , the same that i used in the main method?
    here is the method :
    public static boolean temMaisAlgarismosDoQueAMediaDosAlgarismos(final int number) {
    // the only assert that can be used here is
    assert 0 < number : number ;
              return true
            else return false;Is there another assert that i could use ? if yes, which one?
    Can't use an assert for the return value , cuz its a loigical (true or false).
    Need opinions.
    Thank you
    Josh

    ok here is the method.
    Insert a number which will be passed as a parameter .
    if the the number of digits is greater than the media of the same digits, return true else false.
    e.g : 132 --> Media = 2 number of digits : 3 so return true. simple.
    Can i use another assert beside that one?.
    public static boolean temMaisAlgarismosDoQueAMediaDosAlgarismos(final int number)
           //Assertion: If (numero <= 0) "Error"          
           assert 0 < numero : numero;
              int sum = 0;
              int numero_auxiliar = numero;
              int count = 0;
              int media;
              while (number_aux > 0){
              int digit = number_aux % 10;
              number_aux  /= 10;
              sum += digit;
              if(number >= 0) count++;
              media =(int) (sum / count);
              if(count > media)
                   return true;
              else
                   return false;
         }thks

  • Need help about using sqlplus_exec_template.sql

    I tried to use sqlplus_exec_template.sql to execute our deployed mapping. At dos prompt I typed :
    C:\>sqlplus username/[email protected] @C:\OWB\owb\rtp\sql\sqlplus_exec_template.sql
    rtschema localhost SQL_LOADER CRD_APPL_MAPPING SKIP=0,LOAD=0,LOG_FILE
    NAME=cvcpmapl.log,DIRECT=true,PARALLEL=false,ERRORS=50,ROWS=200,READSIZE=65536,BINDSIZ E=50000,AUDIT=true,PURGEGROUP=wb,target_store_uoid=F0E49963A42E4DB6AFF
    85FFF8E05AB9E
    SQL*Plus: Release 9.2.0.1.0 - Production on Fri May 16 18:32:25 2003
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Session altered.
    Role set.
    Stage 1: Decoding Parameters
    | location_name=localhost:1521:odb
    | task_type=SQL_LOADER
    | task_name=CRD_APPL_MAPPING
    Stage 2: Opening Task
    declare
    ERROR at line 1:
    ORA-20001: Task not found - Please check the Task Type, Name and Location are
    correct.
    ORA-06512: at line 261
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    =================================================
    I am quite sure the task name and task type is correct. The task name is same as the one I saw in runtime repository schema -> table WB_RT_TASKS -> column TASK_NAME
    , but I am very doubt about what should be the correct input for LOCATION, system parameter and custom parameter.
    Can anyone give some help about where could I find the correct input for those parameter?
    Thx in advance.
    Rds
    CH

    I 've tried to use :
    sqlplus username/[email protected] @C:\OWB\owb\rtp\sql\sqlplus_exec_template.sql
    rtschema OWBLOCATION SQL_LOADER CRD_APPL_MAPPING "," ","
    where OWBLOCATION I have used the deploy location of the mapping for my case, created within OWB. The value is CCS_DEPLOY.
    But the error is the same :
    ======================================================
    Stage 1: Decoding Parameters
    | location_name=CCS_DEPLOY
    | task_type=SQL_LOADER
    | task_name=CRD_APPL_MAPPING
    Stage 2: Opening Task
    declare
    ERROR at line 1:
    ORA-20001: Task not found - Please check the Task Type, Name and Location are
    correct.
    ORA-06512: at line 261
    ========================================================
    could you tell me the SQL used by WB_RT_API to get the task from runtime schema. So that I could check the correct location myself.
    Or how could I view the pl/sql of WB_RT_API_EXEC which is wrapped.
    Thx for your help.
    Rg.
    CH

  • Need advise about using NAS drive for TM and other storage

    I have 2 macs. One is running Snow Leopard and has a FW 400 drive connected directly to it for TM backups. I have another older mac (G5 PPC) running Tiger and I plan to update to Leopard so I can also do TM backups for it.
    So, I'm thinking of getting the following NAS enclosure, adding a 2TB drive to it, so I can do TM backups on the old mac (and maybe switch the other mac to use it too).
    The questions I have are:
    1. is it fast enough to do it over the network, compared to the direct FW 400 connection?
    2. Can I partition the new NAS 2TB in half and move the TM backup folder over there and then tell my new mac that it needs to do the TM backup there?
    That's all I have for now. Hope someone can help.
    Thank You!

    That does not appear to be compatible with Time Machine.
    See the pink box in #2 of [Time Machine - Frequently Asked Questions|http://web.me.com/pondini/Time_Machine/FAQ.html] (or use the link in *User Tips* at the top of this forum).

  • Need Info about using Strut with WL 7.0

    I want to find out how to use it with WL 7.0. Would anyone give me any info about it? :) Thanks
              

    You could download and deploy "struts-example.war" from apache website.
              [That Struts 1.0.2 I think.]
              ---Nam
              Jordy wrote:
              > I want to find out how to use it with WL 7.0. Would anyone give me any info about it? :) Thanks
              And God said
              Let there be numbers
              And there were numbers.
              Odd and even created he them,
              He said to them be fruitful and multiply,
              And he commanded them to keep the laws of induction.
              [Bill Taylor [email protected]]
              [nam_nguyen.vcf]
              

  • The Problem about using OTT command line

    Environment variables:
    oracle_home=c:\oracle
    command line:
    ott userid=scott/tiger intype=demoin.typ outtype=demoout.typ code=cpp hfile=demo.h cppfile=demo.cpp mapfile=RegisterMappings.cpp
    error message:
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/ott/c/CMain
    where should I place the all the classes(not only the CMain.class) of oracle package?
    or what others should I have to configure?
    thanks!

    install xe client
    set ORACLE_HOME to the client installation path.
    ******************************ott.bat******************************
    @echo off
    Rem OTT script for Oracle XE .
    Rem Before running this script
    Rem set jdk1.4.2/bin to PATH
    Rem If ORACLE_HOME is not set, set the
    Rem CLASSPATH to the directories containing
    Rem ojdbc14.jar,orai18n.jar and ottclasses.zip
    Rem
    if defined ORACLE_HOME set CLASSPATH=%ORACLE_HOME%\jdbc\lib\ojdbc14.jar;%ORACLE_HOME%\jlib\orai18n.jar;%ORACLE_HOME%\precomp\lib\ottclasses.zip;%CLASSPATH%
    set NLSLANG=
    if defined NLS_LANG set NLSLANG=NLS_LANG
    if defined ORACLE_HOME (
    java oracle.ott.c.CMain nlslang=%NLSLANG% orahome=%ORACLE_HOME% %*
    ) else (
    java oracle.ott.c.CMain nlslang=%NLSLANG% %*
    )

  • Need advice about using a calendar in iweb

    I am wanting to use a calendar in iweb. Does anybody have a suggestion of how this can be done. I've looked at ical and google calendar, but is there something that can be used with html snippet?

    You can use Google calendar as an html snippet, just copy and paste the code. It is found when you go to share calendar - it gives you the html code to embed in your website.

  • Need opinions about RMI tunneling over HTTP please

    My Tomcat Server wants to talk with a JBoss Server.
    This communication has to go through a firewall, and I want to use
    the HTTP tunneling function.
    Can anybody please tell me if the HTTP tunnel has any disadvantages?
    How big is the performanceloss?
    Can anybody please give me a link how to do this? What configurations
    do I have to do where?
    Thanks!

    you do not have to do anything special for this, if you do not want to.
    All yours questions are answered here :
    http://java.sun.com/j2se/1.3/docs/guide/rmi/spec/rmi-arch6.html

  • Need opinions about PSU

    Hello there,
    I am a owner of MSI i865PE NEO2 LS mother board with P4 2.4GHz(800) Northwood CPU, 2x 256MB RAM and GF4 Ti4200
    This system is giving me headackes from day one, and for 3 years now. It is great and stable system, but there is one little dissadvantage. AGP, PCI and MEM slots. They are not welded properly and causing system crashes if there is a slight changes. Basicaly you must leave tha chassis alone and not try to upgrade if you want to boot it up... That's my experience with my MB.
    I've changed PSU cuple of times, because I thought PSU is the cause of system crashes, but recently I realized that it is the AGP slot.
    But this isn't the issue now. The problem I am dealing with now is PSU. When I turned on my PC, Windows XP gave me a blue screen od death, and when I restarted the system went to Windows normaly. But I have realized that one of my CD Drives is not working, I could not open the CD Drive to put a CD in. Then I pluged out the power core and used another one, and when started the system it booted normaly and I could open the CD Drive.
    My question is. What could cause this? Is it possible that the PSU overheated or is it near it's fail period and I must consider in buying a new one. PSU is as old as system (3 years)
    A nother issues I am having are system lockups, but i believe it's the heat... It is summer and it is realy hot in my room ,even system temps are near 44°C, they used to be 36-38.
    Is it possible that the PSU is heating the system to much, and maybe dust is the cause of overheating.
    Thanx you all..

    For 3 years, only until now you said it gave you headaches...
    System temp is pretty high. Also clean up all the dust in the chassis, including all the fans- CPU, chipset, graphics cards and PSU fan, not sure if you could clean it up. Try cleaning up everything first. There are lots of dust trapped in the fins of the heatsink, clean all of them. Also, reapply CPU Thermal grease on your CPU. Clean it up first before you apply the new thermal grease.

  • Use methods of another class

    Dear Sir/madam,
    i have a question about using methods of another class. I will explane:
    i have made a class which is called A. This class has some attributes (studentName and examRank) and some methods.
    Now i need to made another class called B. Now i want to make an array where i can add some attributes of objects which i made of class A. How can i do that?
    Kind regards

    Here's a for-instance that doesn't use your exact program but demonstrates the point:
    public class A
      int value;
      String name;
      public A(int value, String name)
        this.name = name;
        this.value = value;
      public int getValue()
        return value;
      public String getName()
        return name;
      public String toString()
        return name + ": " + value;
    import java.util.Arrays;
    import java.util.Random;
    public class B
      private static final String[] NAMES =
        "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
      private static final int MAX = 100;
      private A[] myAs = new A[NAMES.length];
      private Random random = new Random();
      public B()
        for (int i = 0; i < myAs.length; i++)
          myAs[i] = new A(random.nextInt(MAX), NAMES);
    public String toString()
    return Arrays.toString(myAs);
    public int getTotal()
    int temp = 0;
    for (int i = 0; i < myAs.length; i++)
    temp += myAs[i].getValue();
    return temp;
    public static void main(String[] args)
    B b = new B();
    System.out.println(b);
    System.out.println("Total: " + b.getTotal());

  • Hi, I did an apple account but they didn't asked me about payment methods and now when i need something from Appstore it is written: "this apple id has not yet been used in the iTunes Store" tap reviem. I tapped review and they are asking me to introduce,

    Hi I have created an apple Id but yhey didn't asked me about paymeny methods, and know when i need something from appstore it is written: This apple Id not yet been used in the iTunes Store, tap review....but when i tap review they ask me for a credit card without giving me the opption of ''NONE''. Can you help me?

    What kinda forum is this where nobody helps!
    I am waiting since so many days after leaving a thread and till nobody helped me with a reply.
    If it's a Google PlayStore forum many hundreds of people would have replied.
    Seeking a little help and nobody bothered to give it out to you, I am really annoyed.
    Still waiting for Help!

  • Needs help.....Please about using different classes

    I don't know how to use differenet classes.
    Please tell me how to write class to suit Start. This stuff me up. Please .... help me
    <<My program>>
    //Start
    public class Start
    {  private Artist[] Artists;
    private Record[] records;
    private Person[] Manager;
    private TextMenu makeMenu = new TextMenu();
    public static void main(String[] args)
         Start studio = new Start();
    studio.menu();
    public Start()
    {  //Person.Manager(ManagerName,HouseNumber,StreetNumber,PhoneNumber)
         Manager = new Person[1];
         Manager[0] = new Person("Yangfan",88,"Young ST",11118888);
         //Artist(GroupID,ArtistName,HouseNumber,StreetNumber,PhoneNumber)
         Artists = new Artist[5];
    Artists[0] = new Artist(1,"Backstreet Boys",58,"Music ST",99998888);
    Artists[1] = new Artist(2,"Santana",68,"Music ST",99998899);
    Artists[2] = new Artist(3,"Macy Gray",78,"Music ST",55558888);
    Artists[3] = new Artist(4,"Ricky Martin",88,"Music AVE",77778888);
    Artists[4] = new Artist(5,"Did Rock",55,"Music Road",66667777);
    //Record(RecordingID,RecordName,Artist,StartTime,FinishTime,RecordingDate,GuestArtist1,GuestArtist2)
    records = new Record[6];
    records[0] = new Record(1,"I want it that way",Artists[0],11,12,"05/08/2001",Artists[1],Artists[3]);
    records[1] = new Record(2,"Smooth",Artists[1],11,12,"05/08/2001",Artists[1],"");
    records[2] = new Record(3,"Do something",Artists[2],11,"05/08/2001",Artists[3],"");
    records[3] = new Record(4,"Livin La Vida Loca",Artists[3],11,12,"05/08/2001",Artists[1],Artists[3]);
    records[4] = new Record(5,"Bawitdaba",Artists[4],11,13,"05/08/2001",Artists[1],"");
    records[5] = new Record(6,"The one",Artists[0],11,14,"05/08/2001",Artists[1],"");
    public void menu()
    {  String[] choices = {">>>List Manager Details",">>>List All Artist Names",">>>List An Artist Telephone-Number",">>>Show Details For One Recording",">>>Add A New Recording",">>>List The Recording Costs For All Artists",">>>List Artist's Reocording",">>>Exit Program"};
    while (true)
    {  switch (makeMenu.getChoice(choices))
    {  case 1: showAllArtists();
    break;
    case 2: showAllRecords();
    break;
    case 3: System.exit(0);
    break;
    case 4: System.exit(0);
    break;
    case 5: System.exit(0);
    break;
    case 6: System.exit(0);
    break;
    case 7: System.exit(0);
    break;
    case 8: System.exit(0);
    break;
    default:
    public void showAllArtists()
    {  int numArtists = Artists.length;
    for(int i = 0; i < numArtists; i++)
    {  Artists[i].displayArtistDetails();
    public void showAllRecords()
    {  for (int i = 0; i < records.length; i++)
    {  System.out.println();
    records.printRecordDetails();
    <<Assignment>>
    Due - midnight, Wednesday August 22nd
    This assignment will test your knowledge of Java programming using classes, encapsulation and javadoc.
    The base requirements
    Write a complete Java class to manage a Digital Recording Studio. The studio wants to keep a list of all Artists that use the studio and also wishes to keep track of all Recordings that have been made. An important function of the program is to calculate the time spent making a recording and charge the Artist for the time used.
    You must create at least the following classes, Start, Studio, Person, Artist, Recording, Address. You may create other classes if needed as well
    Start will contain main(), create one instance of a Studio and execute a Menu of commands to test your code. Studio should contain a studio name, an array of Artist and an array of Recording plus the studio manager (a Person). Each Artist should contain the name of the group and an Address. Each Person will have a name and a home address. Each recording will have a Title (usually song title), an Artist (only one), and a list of guestArtist (they are Artist�s but will not receive royalties) the number of the CD the recording is stored on (numbers are numerical and recordings are saved on CD-R), plus the recording start and finish times for the recording session (suggest you use Java Date class � refer to the API). An Address will contain, house number (integers only), a street name and a telephone number. There is no need to store city and country.
    To enter a set of data for testing your program � main() should call a method in the Start class that will fill in a set of values by creating objects and filling in values by calling methods in each class. This is the ONLY method allowed to be longer than 1 page long � normally we would read the data from a file but there are no O-O principles that can be learnt with simply filling in data values. It is suggested to create say at least 4 Artist�s and 6 Recordings (at least one with 1 guest Artist and one with 2 guestArtist�s)
    A menu for testing your program should be provided (it is suggested to put the Menu into a separate class as you need at least 3 menus). While other commands are possible, only the following ones will receive marks.
    Menu commands needed are
    List the Managers name, address and telephone number
    List all Artist Names
    List an Artist telephone number (a sub menu showing valid Artist�s is required)
    Show all details for one Recording ( sub menu of valid Recordings will be needed and remember there can be more than one guestArtist)
    Add a new Recording, user will need to be prompted for all details.
    List the recording costs for all Artists � show each Artist on a separate line with their name and total amount, charge for using the studio is $1000 per hour or part thereof, example for a 1 hour and 10 minute recording the Artist will be billed for 2 hours.
    List all the Recording�s one Artist has worked on (sub menu of Artists needed), the list should show whether they were the Artist or a guestArtist
    Exit program
    Use fixed sizes for arrays, suggest 20 is suitable for all arrays. Java can handle dynamic data structures (where the number of elements can grow or shrink), but that is beyond a first assignment.
    Do NOT make ANY methods static - this defeats the Object Oriented approach and will result in ZERO marks for the entire assignment.
    Data MUST be encapsulated, this means that all the data relating to an object are to be stored INSIDE an object. None of the data detail is to be globally available within your program - hence do not store Artist names in either Studio or Recordings � just store a reference instead. Do NOT create ID numbers for Artists, you should use References instead � for many students this will be the hardest part as you have to use Objects, not program in a C style to solve the problem. Note that if there are any non-private data in classes then zero will given for marks for encapsulation.
    Good programming style is expected (see web page or lecture notes). In particular, you must use javadoc to generate a set of html pages for your classes. Make sure you use the special javadoc style comments in your source code. Marks will be granted for both using javadoc and also for including sensible javadoc comments on each class and each public method.
    What to Hand In
    Read the turnin page, basically the .java files, a readme.txt to tell the marker which file the program starts from plus the javadoc (html) files. Do NOT send .class files (if you do send these we will delete them and recompile your program), do NOT compress with gtar, tar, zip or use any other tool on your files. Turnin automatically compresses all your files into a single archive for us to mark.
    The simplest way to turnin all your files is to place all files in one directory then just use the *.* wildcard to turn in all files within that one directory.
    You must turnin all files that are not part of Java 1.3. In particular, you are allowed (actually encouraged) to use EasyIn or SavitchIn but should include the one you use in the files you submit. It is STRONGLY suggested that you copy all the files into another directory, test it works there by compiling and executing then turnin files from that directory. A common problem is students adding comments at the last minute then not testing if it still compiles. The assignment will be marked as submitted � no asking later for leniency because you added comments at the last minute and failed to check if it still worked.
    If the tutors are unable to compile your submission, they will mark the source code but you will lose all the execution marks. Sorry, but it is your responsibility to test then hand in all files.
    Comments
    For CS807 students, this program should be fairly easy if it was to be programmed in C (you would use several struct). The real art here is to change over to programming objects. Data is contained in an object and is not global. This idea is essential to using Java effectively and is termed encapsulation. Instead of using function(data), you use objectName.method( ). Effectively you switch the data and functions around, the data has a method (function) attached to it, not the other way around as in C (where you have a function and send data to it).
    While there will be some marks for execution, the majority of the marks will be given for how well you write your code (including comments and documentation) and for how well you used O-O principles. Programs written in a C style with most of the code in one class or using static will receive ZERO marks regardless of how well they work.
    You are responsible for checking your turnin by reading the messages turnin responds with. Failure to read these messages will not be an acceptable excuse for submitting an incorrect assignment. About 2% of assignments sent to turnin are unreadable (usually empty) and obtain 0.
    Late submissions
    Late submissions will only be accepted with valid reasons for being late. All requests for assignment extensions must be made via email to the lecturer. Replies for acceptance or refusal will made by email. Instant replies are unrealistic (there is usually a flood of queries into my mail box around assignment due dates) and the best advice is to ask at least 4 days in advance so that you will have a reasonable chance of getting a timely reply and allow yourself enough time to submit something on time if the extension is not granted.
    ALL late submissions will be marked LAST and will NOT be sent to tutors for marking until all other assignments have been marked. As an example, if you submit late and your assignment is not yet marked by the time assignment 2 is due then it will be pushed to the end of the marking pile as the assignments that were submitted on time for assignment 2 will take priority.
    If you make a second submission after the submission date, only the first submission will be marked. We will not mark assignments twice! You can update your submission BEFORE the submission date if you need to - this will just overwrite the first submission. The latest time for a late submission is 5pm on the Wednesday after the due date. This is because, either a solution will be handed out at that lecture or details of the assignment will be discussed at the lecture. I cannot accept any assignment submissions after that time for any reason at all including medical or other valid reasons. For those who are given permission to be later than the maximum submission time � a different assignment will be handed out. Remember, if you decide to submit late you are VERY UNLIKELY to receive feedback on your assignments during semester.
    Assignments will be removed from turnin and archived elsewhere then forwarded to tutors for marking on the morning after the assignment is due. A different tutor will mark each of your assignments � do not expect the tutor you see at the tutorials to be your marker.
    Marks will be returned via email to your computer science yallara account � ideally within 2 weeks. I will send marks out when I receive them so do not send email asking where your marks are just because a friend has theirs. If you want your email forwarded to an external account, then place a valid .forward file into your yallara account. The Help Desk on level 10 can assist you in setting this up if you do not know how to do it.

    I have seen other people who have blatantly asked for
    other people to do their homework for them, but you
    are the first person I've seen to actually cut and
    paste the entire assignment as it was handed to you.
    Amazing.
    Well, unlike some of the people you're talking about, it seems like zyangfan did at least take a stab at it himself, and does have a question that is somewhat more sepcific that "please do this homework for me."
    Zyangfan,
    marendoj is right, though. Posting the entire assignment is kind of tacky. If you want to post some of it to show us what you're trying to do, please trim it down to the essential points. We don't need to see all the instructor's policies and such.
    Anyway, let me see if I understand what you're asking. You said that you know how to write the code, but only by putting it all in one class, is that right? What part about using separate classes do you not understand? Do you not know how to make code in one class aware that the other class exists? Do you not know how code in class A can call a method in class B?
    Please be a bit more specifice about what you don't understand. And at least try using multiple classes, then when you can't figure out why something doesn't work, explain what you did, and what you think should have happened, and what did happen instead.
    To get you started on the basics (and this should have been covered in your course), you write the code for two classes just like for one class. That is, for class A, you create a file A.java and compile it to A.class. For class B, you create a file B.java and compile it to B.class. Given how rudimentary you question is, we'll skip packages for now. Just put all your class files in the same directory, and don't declare packages in the .java files.
    To call a method in class B from code that's in class A, you'll need an object of class B. You instantiate a B, and then call its methods.
    public class B {
      int count;
      public B() { // constructor
      public void increment() {
        count++;
    public class A {
      public static void main(String args[]) {
        B b = new B();
        b.increment();
    }Is this what you were asking?

  • How would I go about adding multiple rectangles using the same lines of code?

    How would I go about adding multiple rectangles using the same lines of code? I would prefer to just run through a set of code every time I need a polygon. If I just have to create multiple polygon adding statements that's fine but I'd prefer just 1.

    >>How would I go about adding multiple rectangles using the same lines of code?
    You could create a method that creates and returns x number of Rectangle elements:
    public IEnumerable<Rectangle> CreateRectangles(int numberOfRectsToCreate)
    for (int i = 0; i < numberOfRectsToCreate; ++i)
    Rectangle rect = new Rectangle();
    rect.Fill = Brushes.Blue;
    rect.Width = 100;
    rect.Height = 100;
    yield return rect;
    ..and then call this method from anywhere in your code:
    IEnumerable<Rectangle> rects = CreateRectangles(5);
    foreach (Rectangle rect in rects)
    //add to StackPanel or do whatever with the Rectangle elements:
    yourStackPanel.Children.Add(rect);
    >>If I just have to create multiple polygon adding statements that's fine but I'd prefer just 1.
    When adding Point objects to a Polygon you can only add one per call to the Add method but you could call the Add method inside a loop, e.g:
    for(int i = 0; i < 10; ++i)
    //add to StackPanel or do whatever with the Rectangle elements:
    Polygon p = new Polygon();
    p.Points.Add(new Point());
    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't post several questions in the same thread.

  • Need help on an assignment using methods.

    The assignment I'm working on uses methods to input an integer and a character and then output a hollow square of the size of the integer and made up of the character entered. This is what I have so far, I'm not quite sure how to fill in the methods....
    import java.util.Scanner; //For scanner class
    public class Methods
    {public static void giveInstructions()
         //instructions
         {System.out.println("Enter a character and an integer. A hollow square of size n times n made up of the character" +
              " will be constructed.");
    public static int getSize (Scanner kbd)
         int size;
         Scanner kbd = new Scanner (System.in);
         System.out.println("     Enter the size: ");
         size = kbd.nextInt();
    public static char getCharacter (Scanner kbd)     
         System.out.println("Enter the Character: ");
         final char ch;
         ch = kbd.nextLine();
    public static void drawSquare(int size, char ch)
    public static void drawSolidLine( int size, char ch )
           String s;
            for( int i = 0; i < size ; i++ )
                    // ADD ch       
           System.out.println( s );
    public static void drawHollowLine( int size, char ch )
                String s = "";
                // add char to s   
               for( int i = 0 ; i < ( size - 2) ; i++ )
                       s = s + " ";
               // Add char to s
              System.out.println( s );
    }I would appreciate any kind of help!

    > I'm really confused. I can't think of anything that I
    would need to write under the main method because
    everything that I need would be under the other
    methods.
    I assume you're replying to me(?). Did you compile and run my example? What is it you don't understand about it? I see your methods are all static so you could do something like this:
    public class Test {
        public static void printA() {
            System.out.println("A");
        public static void printB() {
            System.out.println("B");
        public static void printSomething(String s) {
            System.out.println(s);
        public static void main(String[] args) {
            Test.printA();
            Test.printB();
            Test.printSomething("AB");
    }

Maybe you are looking for

  • Xml parsing innovation

    [ANN] VTD-XML Version 1.5 Released Eight years after the invention of XML, DOM and SAX, despite their respective issues, are still the mainstays of application developers. So is it the end of road for XML parsing innovation? The VTD-XML project team

  • How move main class to script in timeline

    hi , in some component they use main class to load various as files and when i see properties of my document i see the name of this class right down the Script : Action Script 3 whe i click on the pen ( edit ) of this class i see various codes about

  • Plant wise inventory in trial balance / balance sheet

    hi gurus, our client has got 5 plants and wants plant wise inventory in the balance sheet. how can this be achieved.

  • Business delegate

    I hope this topic isn't completely worn out ... I tried looking a bit for relevant info here. I'm looking at mixing and matching an EJB deployment with local and remote interfaces. The Business Delegate pattern seems the way to go. Here, we can encap

  • Markers on Line Chart

    Hi, Can anybody help me with adding markers (think that they are colled like that) to the Line Chart. Please refer to the attached example link Example Is there a Line Chart series option in styles to add those? Please help.