java.lang.String.valueOf()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(218)

本文整理了Java中java.lang.String.valueOf()方法的一些代码示例,展示了String.valueOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。String.valueOf()方法的具体详情如下:
包路径:java.lang.String
类名称:String
方法名:valueOf

String.valueOf介绍

[英]Returns the string representation of the char argument.
[中]返回char参数的字符串表示形式。

代码示例

代码示例来源:origin: google/guava

@Override
 public int compare(T left, T right) {
  return String.valueOf(left).compareTo(String.valueOf(right));
 }
}

代码示例来源:origin: square/okhttp

private List<String> names(List<Certificate> certificates) {
  ArrayList<String> strings = new ArrayList<>();

  for (Certificate cert : certificates) {
   if (cert instanceof X509Certificate) {
    strings.add(String.valueOf(((X509Certificate) cert).getSubjectDN()));
   } else {
    strings.add(cert.getType());
   }
  }

  return strings;
 }
}

代码示例来源:origin: square/okhttp

/**
 * Adds a new header with the name and value. This may be used to add multiple headers with the
 * same name.
 */
public MockResponse addHeader(String name, Object value) {
 headers.add(name, String.valueOf(value));
 return this;
}

代码示例来源:origin: square/okhttp

/**
 * Adds a new header with the name and value. This may be used to add multiple headers with the
 * same name. Unlike {@link #addHeader(String, Object)} this does not validate the name and
 * value.
 */
public MockResponse addHeaderLenient(String name, Object value) {
 Internal.instance.addLenient(headers, name, String.valueOf(value));
 return this;
}

代码示例来源:origin: google/guava

static void fail(Throwable cause, Object message) {
 AssertionFailedError assertionFailedError = new AssertionFailedError(String.valueOf(message));
 assertionFailedError.initCause(cause);
 throw assertionFailedError;
}

代码示例来源:origin: google/guava

@Override
 public String apply(Integer from) {
  return String.valueOf(from);
 }
});

代码示例来源:origin: google/guava

@Override
 public String apply(Integer from) {
  return String.valueOf(from);
 }
}

代码示例来源:origin: ReactiveX/RxJava

private static String getStringValue(Object o) {
  if (o == null) {
    return "";
  } else {
    if (o instanceof int[]) {
      return Arrays.toString((int[]) o);
    } else {
      return String.valueOf(o);
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

private static String getStringValue(Object o) {
  if (o == null) {
    return "";
  } else {
    if (o instanceof int[]) {
      return Arrays.toString((int[]) o);
    } else {
      return String.valueOf(o);
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

private static String getStringValue(Object o) {
  if (o == null) {
    return "";
  } else {
    if (o instanceof int[]) {
      return Arrays.toString((int[]) o);
    } else {
      return String.valueOf(o);
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

private static String getStringValue(Object o) {
  if (o == null) {
    return "";
  } else {
    if (o instanceof int[]) {
      return Arrays.toString((int[]) o);
    } else {
      return String.valueOf(o);
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public Integer apply(Integer t1) {
  // be slow ... but faster than Thread.sleep(1)
  String t = "";
  int s = sink;
  for (int i = 2000; i >= 0; i--) {
    t = String.valueOf(i + t.hashCode() + s);
  }
  sink = t.hashCode();
  return t1;
}

代码示例来源:origin: google/guava

/**
 * Adds a name/value pair to the formatted output in {@code name=value} format.
 *
 * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.add()}).
 */
@CanIgnoreReturnValue
public ToStringHelper add(String name, float value) {
 return addHolder(name, String.valueOf(value));
}

代码示例来源:origin: google/guava

/**
 * Adds a name/value pair to the formatted output in {@code name=value} format.
 *
 * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.add()}).
 */
@CanIgnoreReturnValue
public ToStringHelper add(String name, int value) {
 return addHolder(name, String.valueOf(value));
}

代码示例来源:origin: google/guava

/**
 * Adds a name/value pair to the formatted output in {@code name=value} format.
 *
 * @since 18.0 (since 11.0 as {@code Objects.ToStringHelper.add()}).
 */
@CanIgnoreReturnValue
public ToStringHelper add(String name, long value) {
 return addHolder(name, String.valueOf(value));
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void subscribe(Subscriber<? super String> t1) {
  t1.onSubscribe(new BooleanSubscription());
  System.out.println(count.get() + " @ " + String.valueOf(last - System.currentTimeMillis()));
  last = System.currentTimeMillis();
  if (count.getAndDecrement() == 0) {
    t1.onNext("hello");
    t1.onComplete();
  } else {
    t1.onError(new RuntimeException());
  }
}

代码示例来源:origin: google/guava

private static void assertCastFails(long value) {
 try {
  UnsignedBytes.checkedCast(value);
  fail("Cast to byte should have failed: " + value);
 } catch (IllegalArgumentException ex) {
  assertTrue(
    value + " not found in exception text: " + ex.getMessage(),
    ex.getMessage().contains(String.valueOf(value)));
 }
}

代码示例来源:origin: ReactiveX/RxJava

@SuppressWarnings("rawtypes")
static String value(Notification notification) {
  if (notification.isOnNext()) {
    return String.valueOf(notification.getValue());
  }
  return "null";
}

代码示例来源:origin: ReactiveX/RxJava

@SuppressWarnings("rawtypes")
static String value(Notification notification) {
  if (notification.isOnNext()) {
    return String.valueOf(notification.getValue());
  }
  return "null";
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void subscribe(Observer<? super String> t1) {
  t1.onSubscribe(Disposables.empty());
  System.out.println(count.get() + " @ " + String.valueOf(last - System.currentTimeMillis()));
  last = System.currentTimeMillis();
  if (count.getAndDecrement() == 0) {
    t1.onNext("hello");
    t1.onComplete();
  } else {
    t1.onError(new RuntimeException());
  }
}

相关文章