strings 2
commit
cd49f0ebe3
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.mycompany</groupId>
|
||||||
|
<artifactId>strings2</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.release>24</maven.compiler.release>
|
||||||
|
<exec.mainClass>com.mycompany.strings2.Strings2</exec.mainClass>
|
||||||
|
</properties>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.mycompany.strings2;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author 250406
|
||||||
|
*/
|
||||||
|
public class Strings2 {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// conversão entre tipos de dados
|
||||||
|
// conversão de um tipo de dado para String
|
||||||
|
// String.valueOf(valorAConverter);
|
||||||
|
// conversão de String para int
|
||||||
|
// Integer.parseInt(stringAConverter)
|
||||||
|
// conversão de String para double
|
||||||
|
// Double.parseDouble(stringAConverter)
|
||||||
|
// conversão de String para float
|
||||||
|
// Float.parseFloat(stringAConverter)
|
||||||
|
// conversão de String para long
|
||||||
|
// Long.parseLong(stringAConverter)
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
System.out.println("Introduza um numero");
|
||||||
|
String numero = scanner.nextLine();
|
||||||
|
int numeroInteiro = Integer.parseInt(numero);
|
||||||
|
double numeroDouble = Double.parseDouble(numero);
|
||||||
|
|
||||||
|
for(int i = 0; i < 11; i++){
|
||||||
|
System.out.println(i);
|
||||||
|
|
||||||
|
}
|
||||||
|
for(int i = 10; i > 0; i--){
|
||||||
|
System.out.println(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue