是否可以使用三元运算符执行 2 个操作 In java

Is it possible to do 2 actions with ternary operator In java

我正在尝试让每个数字 7 也变成一个字母。 ex:57 75 157 现在它给了我除以 7

这个词
public class Boomtest {

public static int boom () {
    int boom2 = 0;
    String boom7 = "Boombala";{
    for (boom2 = 0; boom2 <= 200; ++boom2) {
    String print = boom2 % 7 == 0 ? boom7 : Integer.toString(boom2);
    
        }
    }
    return boom2;
    
}

}

  1. 三进制可以吗?
  2. 我怎么能运行它没有字符串打印呢,感觉好像少了什么。

我知道还有其他答案说“不”,比如这个:但是你可以发挥你的想象力来做到这一点,例如你可以创建执行动作的方法,像这样

public static int boom(){
    ...
    int numberToDelete = (/*conditional here*/)?actions01():actions02();
    ...
}
public static int actions01(){
    /*Multiple actions here*/
    return 0;
}
public static int actions02(){
    /*Multiple actions here*/
    return 0;
}

反正我不建议你那样做。

PS: 尝试更正您的身份