
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Java Program to find the perimeter of a cylinder
Following is the Java code to find the perimeter of a cylinder −
Example
import java.io.*; public class Demo{ static int find_peri(int dia, int ht){ return 2*(dia + ht); } public static void main(String[] args){ int dia = 7; int ht = 15; System.out.println("The perimeter of the cylinder is " + find_peri(dia, ht) + " units\n"); } }
Output
The perimeter of the cylinder is 44 units
A class named Demo defines a static function that takes in two values, diameter and height. This function computes the sum of these two values and multiplies it by 2 and returns it as output. The main function defines a value each for the diameter and height. The function is called and parameters are passed to it. Relevant message is displayed on the console.
- Related Articles
- Find the perimeter of a cylinder in Python Program
- Python Program for Find the perimeter of a cylinder
- Find the perimeter of a cylinder in C++
- Java Program to Find the Perimeter of a Rectangle
- Java Program to Find the Perimeter of a Circle
- Swift Program to Find the Perimeter of a Circle
- Swift Program to Find the Perimeter of a Rectangle
- Haskell Program to Find the Perimeter of a Circle
- Kotlin Program to Find the Perimeter of a Rectangle
- Kotlin Program to Find the Perimeter of a Circle
- JavaScript program to find perimeter of a triangle
- Program to find the perimeter of a rhombus using diagonals
- Program to find perimeter of a polygon in Python
- Program to find the Area and Perimeter of a Semicircle in C++
- C program to find the area of circle and cylinder using structures.

Advertisements