| | |
mutlipication table in java program
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
0
#2 Oct 6th, 2009
1) Create a array, which represents a table.
2) use a for loop;
2) use a for loop;
Java Syntax (Toggle Plain Text)
for(int i = 1; i != 5; i++) myArrayTable[i] = 6*i; //say, myArrayTable is already declared.
I give up! 1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e ] 2) What does this sequence equal to : (.5u - .5a)(.5u-.5b)(.5u-.5c) ... 3) What is the 123456789 prime numer? Ask4Answer
0
#3 Oct 6th, 2009
•
•
•
•
1) Create a array, which represents a table.
2) use a for loop;
Java Syntax (Toggle Plain Text)
for(int i = 1; i != 5; i++) myArrayTable[i] = 6*i; //say, myArrayTable is already declared.
Why didn't you use this at the for loop:
Java Syntax (Toggle Plain Text)
for(int i = 1; i < 5; i++)
Check out my New Bike at my Public Profile at the "About Me" tab
•
•
Join Date: Oct 2009
Posts: 14
Reputation:
Solved Threads: 0
1)
Class: Multiply
Attributes: int x
int y
Methods: getters&setters
Constructors
toString
in Main
create array or arraylist of the class Multiply
take in the 2 numbers into each
to print:
iterate through the array and print the "Multiply.toString()" and the "toString()" will include the "x*y = z" to form each line
I would recomend using the IDE's BlueJ or Netbeans (Netbeans does most of it for you hence is my favourite)
any errors in my repllies then pm me please as I am also a learner
Class: Multiply
Attributes: int x
int y
Methods: getters&setters
Constructors
toString
in Main
create array or arraylist of the class Multiply
take in the 2 numbers into each
to print:
iterate through the array and print the "Multiply.toString()" and the "toString()" will include the "x*y = z" to form each line
I would recomend using the IDE's BlueJ or Netbeans (Netbeans does most of it for you hence is my favourite)
any errors in my repllies then pm me please as I am also a learner
0
#7 29 Days Ago
•
•
•
•
I have a question:
Why didn't you use this at the for loop:
Java Syntax (Toggle Plain Text)
for(int i = 1; i < 5; i++)
A thing to note ( at least in c++) is that != is more generic than
'<' because '!=' works with containers like vectors, string map
while '<' is not compatible with all of them. I imagine that
java is similar. It also depends on context btw.
I give up! 1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e ] 2) What does this sequence equal to : (.5u - .5a)(.5u-.5b)(.5u-.5c) ... 3) What is the 123456789 prime numer? Ask4Answer
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 4
0
#8 29 Days Ago
interesting point. I haven't seen the non-equals operator used as a loop conditional before. I have to admit that what you said makes sense. I would have never thought of it in that way before. But . . . what guarantee do you have that you are actually comparing values in c++? wouldn't a statement like objecta != objectb be interpreted as: The address where objecta resides is not equal to the address where objectb resides?
Besides, c++ allows you to overload your operators so there is no ambiguity. The classes you are talking about may have just implemented that.
But as far as comparing primitives? Sure != 5 looks hunky dory. I've been using comparison operators for the last 15 years, so I don't thnink I'll all of the sudden switch though.
Besides, c++ allows you to overload your operators so there is no ambiguity. The classes you are talking about may have just implemented that.
But as far as comparing primitives? Sure != 5 looks hunky dory. I've been using comparison operators for the last 15 years, so I don't thnink I'll all of the sudden switch though.
0
#9 29 Days Ago
>>
"what guarantee do you have that you are actually comparing values in c++?"
<<
In c++ the "!=" operator when used with container from std does not compare address like the "==" in java ( at times), it only compares
the values. The standard C++ library was implemented with generic in
mind.
"what guarantee do you have that you are actually comparing values in c++?"
<<
In c++ the "!=" operator when used with container from std does not compare address like the "==" in java ( at times), it only compares
the values. The standard C++ library was implemented with generic in
mind.
I give up! 1) What word becomes shorter if you add a letter to it? [ Solved by : niek_e ] 2) What does this sequence equal to : (.5u - .5a)(.5u-.5b)(.5u-.5c) ... 3) What is the 123456789 prime numer? Ask4Answer
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 4
0
#10 29 Days Ago
•
•
•
•
In c++ the "!=" operator when used with container from std does not compare address like the "==" in java ( at times), it only compares
the values. The standard C++ library was implemented with generic in
mind.
c++ Syntax (Toggle Plain Text)
someCollection<someClass> someObject[] = new someCollection<someClass>()[2]; someObject[0] = someData; someObject[1] = otherData; if (someObject[0] != someObject[1]) { std::cout << "AHHHHHH!!!! Run for your lives!!! "; }
Also, c++ calls generic types template types. But you knew that.
So . . . should this thread be moved to c++ or did LKH get his answer? Sorry for the rambling.
Last edited by eggmatters; 29 Days Ago at 3:18 pm.
![]() |
Similar Threads
- put the Dos 's command into java program? (Java)
- Running java command thru java program (Java)
- help on this java program. (Java)
- Java program sample for getting Systeminfo (Java)
- JAVA program help (Student/Grades) (Java)
- Help with a java program home work assignment (Java)
Other Threads in the Java Forum
- Previous Thread: Java ActionListener Question
- Next Thread: Merging two files
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary block bluetooth character chat class client code component consumer csv database desktop eclipse error fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javac javaee javaprojects jmf jni jpanel julia linked linux list loop mac map method methods mobile netbeans newbie number objects online oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time title tree tutorial-sample ubuntu update windows working






