Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
root-devvoo
Java-Data_Structure
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
Java-Data_Structure
/
Chapter1
/
src
/
Section2
/
Code16.java
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
26 lines (21 loc) · 1.19 KB
main
Breadcrumbs
Java-Data_Structure
/
Chapter1
/
src
/
Section2
/
Code16.java
Copy path
Top
File metadata and controls
Code
Blame
26 lines (21 loc) · 1.19 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package
Section2
;
import
java
.
util
.
Scanner
;
// 입력으로 두 정수 a와 b를 받아 a의 b승을 계산한다.
public
class
Code16
{
public
static
void
main
(
String
[]
args
) {
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Please enter two integers and press Enter."
);
int
a
=
sc
.
nextInt
();
int
b
=
sc
.
nextInt
();
// 4. 메서드 power가 return문으로 넘겨준 값을 받아서 변수 result에 저장한다.
int
result
=
power
(
a
,
b
);
// 1. 메서드 power를 호출하면서 매개변수로 정수 a와 b의 값을 건낸다
System
.
out
.
println
(
"The result is "
+
result
);
sc
.
close
();
}
public
static
int
power
(
int
n
,
int
m
) {
// 2. 메서드 power는 매개변수로 두 개의 정수를 건내 받으며 각각을 m과 n이라고 이름 짓는다.
int
prod
=
1
;
for
(
int
i
=
0
;
i
<
m
;
i
++)
// i가 m보다 작은 동안 i를 증가시키면 이 for문은 정확히 m번 동작한다.
prod
*=
n
;
// 맨 처음에 prod를 1이라고 하고, 거기에 n을 곱하는 일을 m번 반복하니까 prod는 n의 m승이 된다.
return
prod
;
// 3. 메서드 power는 계산 결과, 즉 변수 prod의 값을 return문을 이용해 자신을 호출한 이에게 넘겨준다.
}
}
You can’t perform that action at this time.