Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 16th, 2006, 12:53 PM   #51
JDStud6
Programmer
 
Join Date: Jan 2005
Location: Charleston, SC www.wareonearth.com
Posts: 57
Rep Power: 4 JDStud6 is on a distinguished road
Send a message via AIM to JDStud6
int[] intArray = new int[10];

intArray[0] = 1;
intArray[1] = 2;
int sum = intArray[0] + intArray[1];

System.out.println("first 2 numbers in array sum to: " + sum);
JDStud6 is offline   Reply With Quote
Old Feb 16th, 2006, 2:00 PM   #52
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 751
Rep Power: 3 Jimbo is on a distinguished road
Java arrays also have a .length property, so you dont have to pass another variable around with them to track their length.

int [] nums = new int[someSize];
/* fill in the array somehow
 * ...
 */
for(int i = 0; i < nums.length; i++)
   System.out.print(nums[i] + " ");

Aside from that, they are very similar. Indexing is the same as C++ (0-based, using []), allocation is always done with new (like any other non-primitive type in Java), and they dont have to be deleted (again, like objects in Java).
Jimbo is offline   Reply With Quote
Old Feb 16th, 2006, 5:18 PM   #53
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
int multi[][] = new int[10][10];

this deals with mulitdimensional arrays, basically creates a table 10 columns by 10 rows
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old Feb 16th, 2006, 7:15 PM   #54
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
thanks you guys!

new question: what is the address for All Java API.. i lost it and cannot find it worth a crap

EDIT: Thanks i found it!

http://java.sun.com/j2se/1.5.0/docs/api/
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Feb 16th, 2006, 7:47 PM   #55
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
got stuck here


file #1:
[php]
import javax.swing.JFrame;

public class lettercount
{
public static void main(String args[])
{
DrawPanel panel=new DrawPanel();

JFrame app=new JFrame();


char[] letterArray=new char[26];
int[] letterCount=new int[26];
int count=0;

for(int i=97;i<=122;i++)
{
letterArray[count]=(char)i;
//System.out.printf("%d = %s\n",count,letterArray[count]);
count++;
}

app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
app.add(panel);
app.setSize(450,250);
app.setVisible(true);

}
}
[/php]

file #2:
[php]
import javax.swing.JPanel;

public class DrawPanel extends JPanel
{

}
[/php]

cannot find quality documentation on compents(Buttons, TextBoxes and other fields) or file manipulation.
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Feb 16th, 2006, 8:24 PM   #56
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
[PHP]
import javax.swing.*;
public class LetterCount

public class lettercount
{
public static void main(String args[])
{
DrawPanel panel=new DrawPanel();
JButton button1 = new JButton("TextOnButton");
JTextArea area = new JTextArea();
JTextField textfield = new JTextField (numberOfcharacterLength);
}
}
[/PHP]

like that?
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old Feb 16th, 2006, 9:12 PM   #57
ANDYCELO
Newbie
 
Join Date: Feb 2006
Posts: 2
Rep Power: 0 ANDYCELO is on a distinguished road
Yes That Is A Good Java Program. If You Are Beginer You Can Not Realy Undestand The Consep Of The Program





:banana:
ANDYCELO is offline   Reply With Quote
Old Feb 16th, 2006, 9:30 PM   #58
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
explain Andy... what do you mean i cannot understand the concept of the program.. i started java literally days ago... and i have been programming for some years.. just within the last year im heavily devoting time to it.

@reggaeton_king: that is declaring them correct?!?
do i add them to the panel using.. .add(TextArea/Button)?
And finally how do i gain control of the components? Such as
Button1_Click?
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Feb 16th, 2006, 11:14 PM   #59
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
grrr .add(JButton) works... but it is added as the size of the entire panel! I cannot find a property or method to alter this in any way and it is highly annoying!!!

Does any know about any good documentation on file i/o???

or on componets and all of there basic properties(height,width,caption,location)...along with gaining control of them.(mouse down[on click], mouse up, mouse move)
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Feb 16th, 2006, 11:40 PM   #60
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 751
Rep Power: 3 Jimbo is on a distinguished road
I'd recommend looking up LayoutManagers from the Java API, especially the FlowLayout, GridLayout, and BorderLayout classes. The GridBagLayout class is another one you can look at, but it's a lot more difficult to get the hang of.

For file I/O, look at the Scanner class (especially with a File argument to the constructor).

For mouse/keyboard events, look at the MouseAdapter class or MouseListener and MouseMotionListener (which are combined into the MouseInputListener, but then you have to write your own function stubs for everything), and KeyListener

Last edited by Jimbo; Feb 16th, 2006 at 11:52 PM.
Jimbo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:49 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC