**power using Math libary**

```
double result = Math.pow(2, 3); // 2^3 = 8
```

**power using Loop**

```
long result = 1;
int a = 3 , b = 2; // a^b
for (int i = 1; i <= b; i++) {
result *= a;
}
System.out.printf("%d^%d is %d ", a, b,result);
```

**power using Math libary**

```
double result = Math.pow(2, 3); // 2^3 = 8
```

**power using Loop**

```
long result = 1;
int a = 3 , b = 2; // a^b
for (int i = 1; i <= b; i++) {
result *= a;
}
System.out.printf("%d^%d is %d ", a, b,result);
```