473,395 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

i am a java beginner

please explain this program and tell the out put of this program..

// Classname must be same as filename.
public class test
{
// Variables
private static String myText = "Hello, World";
private static String msg;
private static int myInt = 10;
// Main - Where the Action Starts
public static void main(String args[])
{
// Print "Hello, World" to the screen.
System.out.println("Hello, World\n");
// Multiplication for each value
for (int i = 0; i <10; i++)
{
// Print Calculations to Screen
System.out.println(calc(i));
}
}
// Handle the calculations
public static String calc(int timesBy)
{
// Put calculation into string
msg = myInt + " x " + timesBy + "= " + (myInt * timesBy) + "\n";

// Return Calculation
return msg;
}
}
Jan 6 '08 #1
6 1163
cerise
15
It simply prints the multiplication table of 10. Its output would be:

Hello, World

10 x 0 = 0
10 x 1 = 10
10 x 2 = 20
10 x 3 = 30
10 x 4 = 40
10 x 5 = 50
10 x 6 = 60
10 x 7 = 70
10 x 8 = 80
10 x 9 = 90

The int variable i are the numbers which are being multiplied to 10. The value of the variable i rises because of the step expression in your for loop. The block after your main block is the method you use to be able to print the calculations (which are these: 10 x 0 = 0, 10 x 1 = 10, etc.). Just ask if you need to anything else explained.
Jan 6 '08 #2
JosAH
11,448 Expert 8TB
Now you've done the OP's homework and s/he can turn it in as if it were his/her own work.

What I don't understand is why the OP didn't compile and run the program. It would've
shown the answer as well.

kind regards,

Jos
Jan 6 '08 #3
cerise
15
Now you've done the OP's homework and s/he can turn it in as if it were his/her own work.

What I don't understand is why the OP didn't compile and run the program. It would've
shown the answer as well.

kind regards,

Jos
I'm sorry, was I not supposed to do that? :( I'll remember the next time.

And can you tell me what an OP is?
Jan 6 '08 #4
JosAH
11,448 Expert 8TB
I'm sorry, was I not supposed to do that? :( I'll remember the next time.

And can you tell me what an OP is?
An OP is an Original Poster, the one who started the thread and no, we're not
supposed to do someone else's homework. A few tips and hints are fine though
but not a boiler plate answer. Read the guidelines (see the 'Help' link in the top
right corner of this page).

kind regards,

Jos
Jan 6 '08 #5
cerise
15
An OP is an Original Poster, the one who started the thread and no, we're not
supposed to do someone else's homework. A few tips and hints are fine though
but not a boiler plate answer. Read the guidelines (see the 'Help' link in the top
right corner of this page).

kind regards,

Jos
Again, I apologize. I've read all the guidelines now, and I'll be sure to remember the guidelines the next time.
Jan 6 '08 #6
JosAH
11,448 Expert 8TB
Again, I apologize. I've read all the guidelines now, and I'll be sure to remember the guidelines the next time.
Apologies accepted of course; we try to help people to be able to do their own
work themselves instead of doing it for them. We believe that it has better
educational value and it keeps away the cheaters ;-)

kind regards,

Jos
Jan 6 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: jcnews | last post by:
I am using Windows XP and am learning how to program in Java. Is there any way to get my fonts to be anti-aliased in both editors and in my programs? The non anti-aliased fonts don't look very...
5
by: Thomas G. Marshall | last post by:
This message is sent to these newsgroups because they are no longer valid: comp.lang.java comp.lang.java.api comp.lang.java.bugs comp.lang.java.misc comp.lang.java.setup comp.lang.java.tech ...
6
by: Alan Brown | last post by:
As a newbie I would like to ask what the difference in application (not details) is between C++ and Java. In what situations would you use C++ in preference to Java and vice versa? I am not...
55
by: Elijah | last post by:
I have read many of the topics on learning C++ or Java first. It seems like everyone says something different. I would like to know if I should learn C++ or Java. First a little about myself. I...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
15
by: RAM | last post by:
Hello, I graduated computer science faculty and decided to became a programmer. Please help me to make a decision: Java or Microsoft .NET? What is the future of Java? Thanks! /RAM/
17
by: JD | last post by:
hi, i m new to java, i want to know if there is a good and free Java IDE that i can use that'll help me, i dont care if its complicated , i just want it to be good, i tried netbeans which comes...
6
crystal2005
by: crystal2005 | last post by:
Hello guys, I'm a beginner in Java application programming. I started to write a Java application in which link to MS Access database. I encountered a problem in deletion function. E.g. I would...
1
by: czi02 | last post by:
Im new to java. ANd somebody out there knows the tutorial of java thanx. for beginner. and how to code it???
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.